winebuild: Support the mingw32 target without an i[3456]86- prefix.
[wine.git] / dlls / glu32 / glu.c
blob46a23369a21592747f6037b08fba8c9e82383e9d
1 /*
2 * Copyright 2001 Marcus Meissner
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(glu);
28 /* The only non-trivial bit of this is the *Tess* functions. Here we
29 need to wrap the callbacks up in a thunk to switch calling
30 conventions, so we use our own tesselator type to store the
31 application's callbacks. wine_gluTessCallback always sets the
32 *_DATA type of callback so that we have access to the polygon_data
33 (which is in fact just wine_tess_t), in the thunk itself we can
34 check whether we should call the _DATA or non _DATA type. */
36 typedef struct {
37 void *tess;
38 void *polygon_data;
39 void (CALLBACK *cb_tess_begin)(int);
40 void (CALLBACK *cb_tess_begin_data)(int, void *);
41 void (CALLBACK *cb_tess_vertex)(void *);
42 void (CALLBACK *cb_tess_vertex_data)(void *, void *);
43 void (CALLBACK *cb_tess_end)(void);
44 void (CALLBACK *cb_tess_end_data)(void *);
45 void (CALLBACK *cb_tess_error)(int);
46 void (CALLBACK *cb_tess_error_data)(int, void *);
47 void (CALLBACK *cb_tess_edge_flag)(int);
48 void (CALLBACK *cb_tess_edge_flag_data)(int, void *);
49 void (CALLBACK *cb_tess_combine)(double *, void *, float *, void **);
50 void (CALLBACK *cb_tess_combine_data)(double *, void *, float *, void **, void *);
51 } wine_tess_t;
53 #define GLU_TESS_BEGIN 100100
54 #define GLU_TESS_VERTEX 100101
55 #define GLU_TESS_END 100102
56 #define GLU_TESS_ERROR 100103
57 #define GLU_TESS_EDGE_FLAG 100104
58 #define GLU_TESS_COMBINE 100105
59 #define GLU_TESS_BEGIN_DATA 100106
60 #define GLU_TESS_VERTEX_DATA 100107
61 #define GLU_TESS_END_DATA 100108
62 #define GLU_TESS_ERROR_DATA 100109
63 #define GLU_TESS_EDGE_FLAG_DATA 100110
64 #define GLU_TESS_COMBINE_DATA 100111
66 /***********************************************************************
67 * gluLookAt (GLU32.@)
69 extern int gluLookAt(double arg0,double arg1,double arg2,double arg3,double arg4,double arg5,double arg6,double arg7,double arg8);
70 int WINAPI wine_gluLookAt(double arg0,double arg1,double arg2,double arg3,double arg4,double arg5,double arg6,double arg7,double arg8) {
71 return gluLookAt(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
74 /***********************************************************************
75 * gluOrtho2D (GLU32.@)
77 extern int gluOrtho2D(double arg0,double arg1,double arg2,double arg3);
78 int WINAPI wine_gluOrtho2D(double arg0,double arg1,double arg2,double arg3) {
79 return gluOrtho2D(arg0,arg1,arg2,arg3);
82 /***********************************************************************
83 * gluPerspective (GLU32.@)
85 extern int gluPerspective(double arg0,double arg1,double arg2,double arg3);
86 int WINAPI wine_gluPerspective(double arg0,double arg1,double arg2,double arg3) {
87 return gluPerspective(arg0,arg1,arg2,arg3);
90 /***********************************************************************
91 * gluPickMatrix (GLU32.@)
93 extern int gluPickMatrix(double arg0,double arg1,double arg2,double arg3,void *arg4);
94 int WINAPI wine_gluPickMatrix(double arg0,double arg1,double arg2,double arg3,void *arg4) {
95 return gluPickMatrix(arg0,arg1,arg2,arg3,arg4);
98 /***********************************************************************
99 * gluProject (GLU32.@)
101 extern int gluProject(double arg0,double arg1,double arg2,void *arg3,void *arg4,void *arg5,void *arg6,void *arg7,void *arg8);
102 int WINAPI wine_gluProject(double arg0,double arg1,double arg2,void *arg3,void *arg4,void *arg5,void *arg6,void *arg7,void *arg8) {
103 return gluProject(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
106 /***********************************************************************
107 * gluUnProject (GLU32.@)
109 extern int gluUnProject(double arg0,double arg1,double arg2,void *arg3,void *arg4,void *arg5,void *arg6,void *arg7,void *arg8);
110 int WINAPI wine_gluUnProject(double arg0,double arg1,double arg2,void *arg3,void *arg4,void *arg5,void *arg6,void *arg7,void *arg8) {
111 return gluUnProject(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
114 /***********************************************************************
115 * gluErrorString (GLU32.@)
117 extern int gluErrorString(int arg0);
118 int WINAPI wine_gluErrorString(int arg0) {
119 return gluErrorString(arg0);
122 /***********************************************************************
123 * gluScaleImage (GLU32.@)
125 extern int gluScaleImage(int arg0,int arg1,int arg2,int arg3,void *arg4,int arg5,int arg6,int arg7,void *arg8);
126 int WINAPI wine_gluScaleImage(int arg0,int arg1,int arg2,int arg3,void *arg4,int arg5,int arg6,int arg7,void *arg8) {
127 return gluScaleImage(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
130 /***********************************************************************
131 * gluBuild1DMipmaps (GLU32.@)
133 extern int gluBuild1DMipmaps(int arg0,int arg1,int arg2,int arg3,int arg4,void *arg5);
134 int WINAPI wine_gluBuild1DMipmaps(int arg0,int arg1,int arg2,int arg3,int arg4,void *arg5) {
135 return gluBuild1DMipmaps(arg0,arg1,arg2,arg3,arg4,arg5);
138 /***********************************************************************
139 * gluBuild2DMipmaps (GLU32.@)
141 extern int gluBuild2DMipmaps(int arg0,int arg1,int arg2,int arg3,int arg4,int arg5,void *arg6);
142 int WINAPI wine_gluBuild2DMipmaps(int arg0,int arg1,int arg2,int arg3,int arg4,int arg5,void *arg6) {
143 return gluBuild2DMipmaps(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
146 /***********************************************************************
147 * gluNewQuadric (GLU32.@)
149 extern int gluNewQuadric(void);
150 int WINAPI wine_gluNewQuadric(void) {
151 return gluNewQuadric();
154 /***********************************************************************
155 * gluDeleteQuadric (GLU32.@)
157 extern int gluDeleteQuadric(void *arg0);
158 int WINAPI wine_gluDeleteQuadric(void *arg0) {
159 return gluDeleteQuadric(arg0);
162 /***********************************************************************
163 * gluQuadricDrawStyle (GLU32.@)
165 extern int gluQuadricDrawStyle(void *arg0,int arg1);
166 int WINAPI wine_gluQuadricDrawStyle(void *arg0,int arg1) {
167 return gluQuadricDrawStyle(arg0,arg1);
170 /***********************************************************************
171 * gluQuadricOrientation (GLU32.@)
173 extern int gluQuadricOrientation(void *arg0,int arg1);
174 int WINAPI wine_gluQuadricOrientation(void *arg0,int arg1) {
175 return gluQuadricOrientation(arg0,arg1);
178 /***********************************************************************
179 * gluQuadricNormals (GLU32.@)
181 extern int gluQuadricNormals(void *arg0,int arg1);
182 int WINAPI wine_gluQuadricNormals(void *arg0,int arg1) {
183 return gluQuadricNormals(arg0,arg1);
186 /***********************************************************************
187 * gluQuadricTexture (GLU32.@)
189 extern int gluQuadricTexture(void *arg0,int arg1);
190 int WINAPI wine_gluQuadricTexture(void *arg0,int arg1) {
191 return gluQuadricTexture(arg0,arg1);
194 /***********************************************************************
195 * gluQuadricCallback (GLU32.@)
197 extern int gluQuadricCallback(void *arg0,int arg1,void *arg2);
198 int WINAPI wine_gluQuadricCallback(void *arg0,int arg1,void *arg2) {
199 return gluQuadricCallback(arg0,arg1,arg2);
202 /***********************************************************************
203 * gluCylinder (GLU32.@)
205 extern int gluCylinder(void *arg0,double arg1,double arg2,double arg3,int arg4,int arg5);
206 int WINAPI wine_gluCylinder(void *arg0,double arg1,double arg2,double arg3,int arg4,int arg5) {
207 return gluCylinder(arg0,arg1,arg2,arg3,arg4,arg5);
210 /***********************************************************************
211 * gluSphere (GLU32.@)
213 extern int gluSphere(void *arg0,double arg1,int arg2,int arg3);
214 int WINAPI wine_gluSphere(void *arg0,double arg1,int arg2,int arg3) {
215 return gluSphere(arg0,arg1,arg2,arg3);
218 /***********************************************************************
219 * gluDisk (GLU32.@)
221 extern int gluDisk(void *arg0,double arg1,double arg2,int arg3,int arg4);
222 int WINAPI wine_gluDisk(void *arg0,double arg1,double arg2,int arg3,int arg4) {
223 return gluDisk(arg0,arg1,arg2,arg3,arg4);
226 /***********************************************************************
227 * gluPartialDisk (GLU32.@)
229 extern int gluPartialDisk(void *arg0,double arg1,double arg2,int arg3,int arg4,double arg5,double arg6);
230 int WINAPI wine_gluPartialDisk(void *arg0,double arg1,double arg2,int arg3,int arg4,double arg5,double arg6) {
231 return gluPartialDisk(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
234 /***********************************************************************
235 * gluNewNurbsRenderer (GLU32.@)
237 extern int gluNewNurbsRenderer(void);
238 int WINAPI wine_gluNewNurbsRenderer(void) {
239 return gluNewNurbsRenderer();
242 /***********************************************************************
243 * gluDeleteNurbsRenderer (GLU32.@)
245 extern int gluDeleteNurbsRenderer(void *arg0);
246 int WINAPI wine_gluDeleteNurbsRenderer(void *arg0) {
247 return gluDeleteNurbsRenderer(arg0);
250 /***********************************************************************
251 * gluLoadSamplingMatrices (GLU32.@)
253 extern int gluLoadSamplingMatrices(void *arg0,void *arg1,void *arg2,void *arg3);
254 int WINAPI wine_gluLoadSamplingMatrices(void *arg0,void *arg1,void *arg2,void *arg3) {
255 return gluLoadSamplingMatrices(arg0,arg1,arg2,arg3);
258 /***********************************************************************
259 * gluNurbsProperty (GLU32.@)
261 extern int gluNurbsProperty(void *arg0,int arg1,int arg2);
262 int WINAPI wine_gluNurbsProperty(void *arg0,int arg1,int arg2) {
263 return gluNurbsProperty(arg0,arg1,arg2);
266 /***********************************************************************
267 * gluGetNurbsProperty (GLU32.@)
269 extern int gluGetNurbsProperty(void *arg0,int arg1,void *arg2);
270 int WINAPI wine_gluGetNurbsProperty(void *arg0,int arg1,void *arg2) {
271 return gluGetNurbsProperty(arg0,arg1,arg2);
274 /***********************************************************************
275 * gluBeginCurve (GLU32.@)
277 extern int gluBeginCurve(void *arg0);
278 int WINAPI wine_gluBeginCurve(void *arg0) {
279 return gluBeginCurve(arg0);
282 /***********************************************************************
283 * gluEndCurve (GLU32.@)
285 extern int gluEndCurve(void *arg0);
286 int WINAPI wine_gluEndCurve(void *arg0) {
287 return gluEndCurve(arg0);
290 /***********************************************************************
291 * gluNurbsCurve (GLU32.@)
293 extern int gluNurbsCurve(void *arg0,int arg1,void *arg2,int arg3,void *arg4,int arg5,int arg6);
294 int WINAPI wine_gluNurbsCurve(void *arg0,int arg1,void *arg2,int arg3,void *arg4,int arg5,int arg6) {
295 return gluNurbsCurve(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
298 /***********************************************************************
299 * gluBeginSurface (GLU32.@)
301 extern int gluBeginSurface(void *arg0);
302 int WINAPI wine_gluBeginSurface(void *arg0) {
303 return gluBeginSurface(arg0);
306 /***********************************************************************
307 * gluEndSurface (GLU32.@)
309 extern int gluEndSurface(void *arg0);
310 int WINAPI wine_gluEndSurface(void *arg0) {
311 return gluEndSurface(arg0);
314 /***********************************************************************
315 * gluNurbsSurface (GLU32.@)
317 extern int gluNurbsSurface(void *arg0,int arg1,void *arg2,int arg3,void *arg4,int arg5,int arg6,void *arg7,int arg8,int arg9,int arg10);
318 int WINAPI wine_gluNurbsSurface(void *arg0,int arg1,void *arg2,int arg3,void *arg4,int arg5,int arg6,void *arg7,int arg8,int arg9,int arg10) {
319 return gluNurbsSurface(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
322 /***********************************************************************
323 * gluBeginTrim (GLU32.@)
325 extern int gluBeginTrim(void *arg0);
326 int WINAPI wine_gluBeginTrim(void *arg0) {
327 return gluBeginTrim(arg0);
330 /***********************************************************************
331 * gluEndTrim (GLU32.@)
333 extern int gluEndTrim(void *arg0);
334 int WINAPI wine_gluEndTrim(void *arg0) {
335 return gluEndTrim(arg0);
338 /***********************************************************************
339 * gluPwlCurve (GLU32.@)
341 extern int gluPwlCurve(void *arg0,int arg1,void *arg2,int arg3,int arg4);
342 int WINAPI wine_gluPwlCurve(void *arg0,int arg1,void *arg2,int arg3,int arg4) {
343 return gluPwlCurve(arg0,arg1,arg2,arg3,arg4);
346 /***********************************************************************
347 * gluNurbsCallback (GLU32.@)
349 extern int gluNurbsCallback(void *arg0,int arg1,void *arg2);
350 int WINAPI wine_gluNurbsCallback(void *arg0,int arg1,void *arg2) {
351 return gluNurbsCallback(arg0,arg1,arg2);
354 /***********************************************************************
355 * gluBeginPolygon (GLU32.@)
357 extern int gluBeginPolygon(void *arg0);
358 int WINAPI wine_gluBeginPolygon(void *arg0) {
359 return gluBeginPolygon(arg0);
362 /***********************************************************************
363 * gluEndPolygon (GLU32.@)
365 extern int gluEndPolygon(void *arg0);
366 int WINAPI wine_gluEndPolygon(void *arg0) {
367 return gluEndPolygon(arg0);
370 /***********************************************************************
371 * gluNextContour (GLU32.@)
373 extern int gluNextContour(void *arg0,int arg1);
374 int WINAPI wine_gluNextContour(void *arg0,int arg1) {
375 return gluNextContour(arg0,arg1);
378 /***********************************************************************
379 * gluGetString (GLU32.@)
381 extern int gluGetString(int arg0);
382 int WINAPI wine_gluGetString(int arg0) {
383 return gluGetString(arg0);
386 /***********************************************************************
387 * gluCheckExtension (GLU32.@)
389 int WINAPI
390 wine_gluCheckExtension( const char *extName, void *extString ) {
391 return 0;
394 extern void *gluNewTess(void);
395 extern void gluDeleteTess(void *);
397 /***********************************************************************
398 * gluNewTess (GLU32.@)
400 void * WINAPI wine_gluNewTess(void)
402 void *tess;
403 wine_tess_t *ret;
405 if((tess = gluNewTess()) == NULL)
406 return NULL;
408 ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
409 if(!ret) {
410 gluDeleteTess(tess);
411 return NULL;
413 ret->tess = tess;
414 return ret;
417 /***********************************************************************
418 * gluDeleteTess (GLU32.@)
420 void WINAPI wine_gluDeleteTess(void *tess)
422 wine_tess_t *wine_tess = tess;
423 gluDeleteTess(wine_tess->tess);
424 HeapFree(GetProcessHeap(), 0, wine_tess);
425 return;
428 /***********************************************************************
429 * gluTessBeginPolygon (GLU32.@)
431 extern void gluTessBeginPolygon(void *, void *);
432 void WINAPI wine_gluTessBeginPolygon(void *tess, void *polygon_data)
434 wine_tess_t *wine_tess = tess;
435 wine_tess->polygon_data = polygon_data;
437 gluTessBeginPolygon(wine_tess->tess, wine_tess);
440 /***********************************************************************
441 * gluTessEndPolygon (GLU32.@)
443 extern void gluTessEndPolygon(void *);
444 void WINAPI wine_gluTessEndPolygon(void *tess)
446 wine_tess_t *wine_tess = tess;
447 gluTessEndPolygon(wine_tess->tess);
451 static void wine_glu_tess_begin_data(int type, wine_tess_t *wine_tess)
453 if(wine_tess->cb_tess_begin_data)
454 wine_tess->cb_tess_begin_data(type, wine_tess->polygon_data);
455 else
456 wine_tess->cb_tess_begin(type);
459 static void wine_glu_tess_vertex_data(void *vertex_data, wine_tess_t *wine_tess)
461 if(wine_tess->cb_tess_vertex_data)
462 wine_tess->cb_tess_vertex_data(vertex_data, wine_tess->polygon_data);
463 else
464 wine_tess->cb_tess_vertex(vertex_data);
467 static void wine_glu_tess_end_data(wine_tess_t *wine_tess)
469 if(wine_tess->cb_tess_end_data)
470 wine_tess->cb_tess_end_data(wine_tess->polygon_data);
471 else
472 wine_tess->cb_tess_end();
475 static void wine_glu_tess_error_data(int error, wine_tess_t *wine_tess)
477 if(wine_tess->cb_tess_error_data)
478 wine_tess->cb_tess_error_data(error, wine_tess->polygon_data);
479 else
480 wine_tess->cb_tess_error(error);
483 static void wine_glu_tess_edge_flag_data(int flag, wine_tess_t *wine_tess)
485 if(wine_tess->cb_tess_edge_flag_data)
486 wine_tess->cb_tess_edge_flag_data(flag, wine_tess->polygon_data);
487 else
488 wine_tess->cb_tess_edge_flag(flag);
491 static void wine_glu_tess_combine_data(double *coords, void *vertex_data, float *weight, void **outData,
492 wine_tess_t *wine_tess)
494 if(wine_tess->cb_tess_combine_data)
495 wine_tess->cb_tess_combine_data(coords, vertex_data, weight, outData, wine_tess->polygon_data);
496 else
497 wine_tess->cb_tess_combine(coords, vertex_data, weight, outData);
501 /***********************************************************************
502 * gluTessCallback (GLU32.@)
504 extern void gluTessCallback(void *,int,void *);
505 void WINAPI wine_gluTessCallback(void *tess,int which,void *fn)
507 wine_tess_t *wine_tess = tess;
508 switch(which) {
509 case GLU_TESS_BEGIN:
510 wine_tess->cb_tess_begin = fn;
511 fn = wine_glu_tess_begin_data;
512 which += 6;
513 break;
514 case GLU_TESS_VERTEX:
515 wine_tess->cb_tess_vertex = fn;
516 fn = wine_glu_tess_vertex_data;
517 which += 6;
518 break;
519 case GLU_TESS_END:
520 wine_tess->cb_tess_end = fn;
521 fn = wine_glu_tess_end_data;
522 which += 6;
523 break;
524 case GLU_TESS_ERROR:
525 wine_tess->cb_tess_error = fn;
526 fn = wine_glu_tess_error_data;
527 which += 6;
528 break;
529 case GLU_TESS_EDGE_FLAG:
530 wine_tess->cb_tess_edge_flag = fn;
531 fn = wine_glu_tess_edge_flag_data;
532 which += 6;
533 break;
534 case GLU_TESS_COMBINE:
535 wine_tess->cb_tess_combine = fn;
536 fn = wine_glu_tess_combine_data;
537 which += 6;
538 break;
539 case GLU_TESS_BEGIN_DATA:
540 wine_tess->cb_tess_begin_data = fn;
541 fn = wine_glu_tess_begin_data;
542 break;
543 case GLU_TESS_VERTEX_DATA:
544 wine_tess->cb_tess_vertex_data = fn;
545 fn = wine_glu_tess_vertex_data;
546 break;
547 case GLU_TESS_END_DATA:
548 wine_tess->cb_tess_end_data = fn;
549 fn = wine_glu_tess_end_data;
550 break;
551 case GLU_TESS_ERROR_DATA:
552 wine_tess->cb_tess_error_data = fn;
553 fn = wine_glu_tess_error_data;
554 break;
555 case GLU_TESS_EDGE_FLAG_DATA:
556 wine_tess->cb_tess_edge_flag_data = fn;
557 fn = wine_glu_tess_edge_flag_data;
558 break;
559 case GLU_TESS_COMBINE_DATA:
560 wine_tess->cb_tess_combine_data = fn;
561 fn = wine_glu_tess_combine_data;
562 break;
563 default:
564 ERR("Unknown callback %d\n", which);
565 break;
567 gluTessCallback(wine_tess->tess, which, fn);
570 /***********************************************************************
571 * gluTessBeginContour (GLU32.@)
573 extern void gluTessBeginContour(void *);
574 void WINAPI wine_gluTessBeginContour(void *tess)
576 wine_tess_t *wine_tess = tess;
577 gluTessBeginContour(wine_tess->tess);
580 /***********************************************************************
581 * gluTessEndContour (GLU32.@)
583 extern void gluTessEndContour(void *);
584 void WINAPI wine_gluTessEndContour(void *tess)
586 wine_tess_t *wine_tess = tess;
587 gluTessEndContour(wine_tess->tess);
590 /***********************************************************************
591 * gluTessVertex (GLU32.@)
593 extern void gluTessVertex(void *, void *, void *);
594 void WINAPI wine_gluTessVertex(void *tess,void *arg1,void *arg2)
596 wine_tess_t *wine_tess = tess;
597 gluTessVertex(wine_tess->tess, arg1, arg2);
601 /***********************************************************************
602 * gluTessProperty (GLU32.@)
604 extern void gluTessProperty(void *, int, double);
605 void WINAPI wine_gluTessProperty(void *tess, int arg1, double arg2)
607 wine_tess_t *wine_tess = tess;
608 gluTessProperty(wine_tess->tess, arg1, arg2);
611 /***********************************************************************
612 * gluTessNormal (GLU32.@)
614 extern void gluTessNormal(void *, double, double, double);
615 void WINAPI wine_gluTessNormal(void *tess, double arg1, double arg2, double arg3)
617 wine_tess_t *wine_tess = tess;
618 gluTessNormal(wine_tess->tess, arg1, arg2, arg3);