d3d11/tests: Add some tests for ID3DUserDefinedAnnotation.
[wine.git] / dlls / glu32 / glu.c
blob8b045ea4438f3ba8959946f6e8624f43120318f2
1 /*
2 * Copyright 2001 Marcus Meissner
3 * Copyright 2017 Alexandre Julliard
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <assert.h>
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
26 #include "wine/wgl.h"
27 #include "wine/glu.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(glu);
32 static const struct { GLuint err; const char *str; } errors[] =
34 { GL_NO_ERROR, "no error" },
35 { GL_INVALID_ENUM, "invalid enumerant" },
36 { GL_INVALID_VALUE, "invalid value" },
37 { GL_INVALID_OPERATION, "invalid operation" },
38 { GL_STACK_OVERFLOW, "stack overflow" },
39 { GL_STACK_UNDERFLOW, "stack underflow" },
40 { GL_OUT_OF_MEMORY, "out of memory" },
41 { GL_TABLE_TOO_LARGE, "table too large" },
42 { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
43 { GLU_INVALID_ENUM, "invalid enumerant" },
44 { GLU_INVALID_VALUE, "invalid value" },
45 { GLU_OUT_OF_MEMORY, "out of memory" },
46 { GLU_INCOMPATIBLE_GL_VERSION, "incompatible gl version" },
47 { GLU_TESS_ERROR1, "gluTessBeginPolygon() must precede a gluTessEndPolygon()" },
48 { GLU_TESS_ERROR2, "gluTessBeginContour() must precede a gluTessEndContour()" },
49 { GLU_TESS_ERROR3, "gluTessEndPolygon() must follow a gluTessBeginPolygon()" },
50 { GLU_TESS_ERROR4, "gluTessEndContour() must follow a gluTessBeginContour()" },
51 { GLU_TESS_ERROR5, "a coordinate is too large" },
52 { GLU_TESS_ERROR6, "need combine callback" },
53 { GLU_NURBS_ERROR1, "spline order un-supported" },
54 { GLU_NURBS_ERROR2, "too few knots" },
55 { GLU_NURBS_ERROR3, "valid knot range is empty" },
56 { GLU_NURBS_ERROR4, "decreasing knot sequence knot" },
57 { GLU_NURBS_ERROR5, "knot multiplicity greater than order of spline" },
58 { GLU_NURBS_ERROR6, "gluEndCurve() must follow gluBeginCurve()" },
59 { GLU_NURBS_ERROR7, "gluBeginCurve() must precede gluEndCurve()" },
60 { GLU_NURBS_ERROR8, "missing or extra geometric data" },
61 { GLU_NURBS_ERROR9, "can't draw piecewise linear trimming curves" },
62 { GLU_NURBS_ERROR10, "missing or extra domain data" },
63 { GLU_NURBS_ERROR11, "missing or extra domain data" },
64 { GLU_NURBS_ERROR12, "gluEndTrim() must precede gluEndSurface()" },
65 { GLU_NURBS_ERROR13, "gluBeginSurface() must precede gluEndSurface()" },
66 { GLU_NURBS_ERROR14, "curve of improper type passed as trim curve" },
67 { GLU_NURBS_ERROR15, "gluBeginSurface() must precede gluBeginTrim()" },
68 { GLU_NURBS_ERROR16, "gluEndTrim() must follow gluBeginTrim()" },
69 { GLU_NURBS_ERROR17, "gluBeginTrim() must precede gluEndTrim()" },
70 { GLU_NURBS_ERROR18, "invalid or missing trim curve" },
71 { GLU_NURBS_ERROR19, "gluBeginTrim() must precede gluPwlCurve()" },
72 { GLU_NURBS_ERROR20, "piecewise linear trimming curve referenced twice" },
73 { GLU_NURBS_ERROR21, "piecewise linear trimming curve and nurbs curve mixed" },
74 { GLU_NURBS_ERROR22, "improper usage of trim data type" },
75 { GLU_NURBS_ERROR23, "nurbs curve referenced twice" },
76 { GLU_NURBS_ERROR24, "nurbs curve and piecewise linear trimming curve mixed" },
77 { GLU_NURBS_ERROR25, "nurbs surface referenced twice" },
78 { GLU_NURBS_ERROR26, "invalid property" },
79 { GLU_NURBS_ERROR27, "gluEndSurface() must follow gluBeginSurface()" },
80 { GLU_NURBS_ERROR28, "intersecting or misoriented trim curves" },
81 { GLU_NURBS_ERROR29, "intersecting trim curves" },
82 { GLU_NURBS_ERROR30, "UNUSED" },
83 { GLU_NURBS_ERROR31, "unconnected trim curves" },
84 { GLU_NURBS_ERROR32, "unknown knot error" },
85 { GLU_NURBS_ERROR33, "negative vertex count encountered" },
86 { GLU_NURBS_ERROR34, "negative byte-stride encountered" },
87 { GLU_NURBS_ERROR35, "unknown type descriptor" },
88 { GLU_NURBS_ERROR36, "null control point reference" },
89 { GLU_NURBS_ERROR37, "duplicate point on piecewise linear trimming curve" },
93 /***********************************************************************
94 * gluErrorString (GLU32.@)
96 const GLubyte * WINAPI wine_gluErrorString( GLenum errCode )
98 unsigned int i;
100 for (i = 0; i < ARRAY_SIZE(errors); i++)
101 if (errors[i].err == errCode) return (const GLubyte *)errors[i].str;
103 return NULL;
106 /***********************************************************************
107 * gluErrorUnicodeStringEXT (GLU32.@)
109 const WCHAR * WINAPI wine_gluErrorUnicodeStringEXT( GLenum errCode )
111 static WCHAR errorsW[ARRAY_SIZE(errors)][64];
112 unsigned int i, j;
114 for (i = 0; i < ARRAY_SIZE(errors); i++)
116 if (errors[i].err != errCode) continue;
117 if (!errorsW[i][0]) /* errors use only ASCII, do a simple mapping */
118 for (j = 0; errors[i].str[j]; j++) errorsW[i][j] = (WCHAR)errors[i].str[j];
119 return errorsW[i];
121 return NULL;
124 /***********************************************************************
125 * gluNewNurbsRenderer (GLU32.@)
127 GLUnurbs * WINAPI wine_gluNewNurbsRenderer(void)
129 ERR( "Nurbs renderer is not supported, please report\n" );
130 return NULL;
133 /***********************************************************************
134 * gluDeleteNurbsRenderer (GLU32.@)
136 void WINAPI wine_gluDeleteNurbsRenderer( GLUnurbs *nobj )
138 assert( 0 );
141 /***********************************************************************
142 * gluLoadSamplingMatrices (GLU32.@)
144 void WINAPI wine_gluLoadSamplingMatrices( GLUnurbs *nobj, const GLfloat modelMatrix[16],
145 const GLfloat projMatrix[16], const GLint viewport[4] )
147 assert( 0 );
150 /***********************************************************************
151 * gluNurbsProperty (GLU32.@)
153 void WINAPI wine_gluNurbsProperty( GLUnurbs *nobj, GLenum property, GLfloat value )
155 assert( 0 );
158 /***********************************************************************
159 * gluGetNurbsProperty (GLU32.@)
161 void WINAPI wine_gluGetNurbsProperty( GLUnurbs *nobj, GLenum property, GLfloat *value )
163 assert( 0 );
166 /***********************************************************************
167 * gluBeginCurve (GLU32.@)
169 void WINAPI wine_gluBeginCurve( GLUnurbs *nobj )
171 assert( 0 );
174 /***********************************************************************
175 * gluEndCurve (GLU32.@)
177 void WINAPI wine_gluEndCurve( GLUnurbs *nobj )
179 assert( 0 );
182 /***********************************************************************
183 * gluNurbsCurve (GLU32.@)
185 void WINAPI wine_gluNurbsCurve( GLUnurbs *nobj, GLint nknots, GLfloat *knot,
186 GLint stride, GLfloat *ctlarray, GLint order, GLenum type )
188 assert( 0 );
191 /***********************************************************************
192 * gluBeginSurface (GLU32.@)
194 void WINAPI wine_gluBeginSurface( GLUnurbs *nobj )
196 assert( 0 );
199 /***********************************************************************
200 * gluEndSurface (GLU32.@)
202 void WINAPI wine_gluEndSurface( GLUnurbs *nobj )
204 assert( 0 );
207 /***********************************************************************
208 * gluNurbsSurface (GLU32.@)
210 void WINAPI wine_gluNurbsSurface( GLUnurbs *nobj, GLint sknot_count, float *sknot, GLint tknot_count,
211 GLfloat *tknot, GLint s_stride, GLint t_stride, GLfloat *ctlarray,
212 GLint sorder, GLint torder, GLenum type )
214 assert( 0 );
217 /***********************************************************************
218 * gluBeginTrim (GLU32.@)
220 void WINAPI wine_gluBeginTrim( GLUnurbs *nobj )
222 assert( 0 );
225 /***********************************************************************
226 * gluEndTrim (GLU32.@)
228 void WINAPI wine_gluEndTrim( GLUnurbs *nobj )
230 assert( 0 );
233 /***********************************************************************
234 * gluPwlCurve (GLU32.@)
236 void WINAPI wine_gluPwlCurve( GLUnurbs *nobj, GLint count, GLfloat *array, GLint stride, GLenum type )
238 assert( 0 );
241 /***********************************************************************
242 * gluNurbsCallback (GLU32.@)
244 void WINAPI wine_gluNurbsCallback( GLUnurbs *nobj, GLenum which, void (CALLBACK *fn)(void) )
246 assert( 0 );
249 /***********************************************************************
250 * gluGetString (GLU32.@)
252 const GLubyte * WINAPI wine_gluGetString( GLenum name )
254 switch (name)
256 case GLU_VERSION: return (const GLubyte *)"1.2.2.0 Microsoft Corporation"; /* sic */
257 case GLU_EXTENSIONS: return (const GLubyte *)"";
259 return NULL;
262 /***********************************************************************
263 * gluCheckExtension (GLU32.@)
265 GLboolean WINAPI wine_gluCheckExtension( const GLubyte *extName, const GLubyte *extString )
267 const char *list = (const char *)extString;
268 const char *ext = (const char *)extName;
269 size_t len = strlen( ext );
271 while (list)
273 while (*list == ' ') list++;
274 if (!strncmp( list, ext, len ) && (!list[len] || list[len] == ' ')) return GLU_TRUE;
275 list = strchr( list, ' ' );
277 return GLU_FALSE;