Merged in master to get version fixes
[sdlgit/SDL_perl.git] / src / OpenGL.xs
1 //
2 // OpenGL.xs
3 //
4 // Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
5 //
6 // ------------------------------------------------------------------------------
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Lesser General Public License for more details.
17 // 
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 //
22 // ------------------------------------------------------------------------------
23 //
24 // Please feel free to send questions, suggestions or improvements to:
25 //
26 //      David J. Goehrig
27 //      dgoehrig@cpan.org
28 //
29
30 #include "EXTERN.h"
31 #include "perl.h"
32 #include "XSUB.h"
33
34 #ifndef aTHX_
35 #define aTHX_
36 #endif
37
38 #include <SDL.h>
39
40 #ifdef PERL_DARWIN
41 #include <gl.h>
42 #include <glu.h>
43 #else
44 #include <GL/gl.h>
45
46 #if defined(__WIN32__) && defined(__MINGW32__)
47 /* 
48 this is a sort of dirty hack - MS Windows supports just OpenGL 1.1 and all 1.2+
49 related stuff was moved from GL/gl.h to GL/glext.h; however this separation
50 was done not properly and even if we are OK with OpenGL 1.1 there are some
51 constants missing in GL/gl.h thus we need also GL/glext.h
52 */
53 #include <GL/glext.h>
54 #undef GL_VERSION_1_3
55 #undef GL_VERSION_1_2
56 #endif
57
58 #include <GL/glu.h>
59 #endif
60
61
62 #ifdef USE_THREADS
63 #define HAVE_TLS_CONTEXT
64 #endif
65
66 #ifndef GL_ALL_CLIENT_ATTRIB_BITS  
67 #define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFF
68 #endif /* GL_ALL_CLIENT_BITS */  
69
70 #include "../../src/defines.h"
71
72 SV* sdl_perl_nurbs_error_hook;
73 void
74 sdl_perl_nurbs_error_callback ( GLenum errorCode )
75 {
76         ENTER_TLS_CONTEXT
77         dSP;
78
79         ENTER;
80         SAVETMPS;
81         PUSHMARK(SP);
82         XPUSHs(sv_2mortal(newSViv(errorCode)));
83         PUTBACK;
84
85         call_sv(sdl_perl_nurbs_error_hook,G_VOID);
86         
87         FREETMPS;
88         LEAVE;
89         LEAVE_TLS_CONTEXT       
90 }
91
92 void
93 sdl_perl_nurbs_being_callback ( GLenum type, void *cb )
94 {
95         SV *cmd;
96         ENTER_TLS_CONTEXT
97         dSP;
98
99         cmd = (SV*)cb;
100
101         ENTER;
102         SAVETMPS;
103         PUSHMARK(SP);
104         XPUSHs(sv_2mortal(newSViv(type)));
105         PUTBACK;
106
107         call_sv(cmd,G_VOID);
108         
109         FREETMPS;
110         LEAVE;
111         LEAVE_TLS_CONTEXT       
112 }
113
114 void
115 sdl_perl_nurbs_multi_callback ( GLfloat *vec, void *cb )
116 {
117         SV *cmd;
118         ENTER_TLS_CONTEXT
119         dSP;
120
121         cmd = (SV*)cb;
122
123         ENTER;
124         SAVETMPS;
125         PUSHMARK(SP);
126         XPUSHs(sv_2mortal(newSViv(PTR2IV(vec))));
127         PUTBACK;
128
129         call_sv(cmd,G_VOID);
130         
131         FREETMPS;
132         LEAVE;
133         LEAVE_TLS_CONTEXT       
134 }
135
136 void
137 sdl_perl_nurbs_end_callback ( void *cb )
138 {
139         SV *cmd;
140         ENTER_TLS_CONTEXT
141
142         cmd = (SV*)cb;
143
144         ENTER;
145         SAVETMPS;
146
147         call_sv(cmd,G_VOID);
148         
149         FREETMPS;
150         LEAVE;
151         LEAVE_TLS_CONTEXT       
152 }
153
154 void
155 sdl_perl_tess_end_callback ( void *cb )
156 {
157         SV *cmd;
158         ENTER_TLS_CONTEXT
159         dSP;
160
161         cmd = (SV*)cb;
162
163         ENTER;
164         SAVETMPS;
165         PUSHMARK(SP);
166         XPUSHs(sv_2mortal(newSViv(GLU_TESS_BEGIN)));
167         PUTBACK;
168
169         call_sv(cmd,G_VOID);
170
171         FREETMPS;
172         LEAVE;
173         LEAVE_TLS_CONTEXT
174 }
175
176 void
177 sdl_perl_tess_begin_callback ( GLenum type,  void *cb )
178 {
179         SV *cmd;
180         ENTER_TLS_CONTEXT
181         dSP;
182
183         cmd = (SV*)cb;
184
185         ENTER;
186         SAVETMPS;
187         PUSHMARK(SP);
188         XPUSHs(sv_2mortal(newSViv(GLU_TESS_BEGIN)));
189         XPUSHs(sv_2mortal(newSViv(type)));
190         PUTBACK;
191
192         call_sv(cmd,G_VOID);
193
194         FREETMPS;
195         LEAVE;
196         LEAVE_TLS_CONTEXT
197 }
198
199 void
200 sdl_perl_tess_error_callback ( GLenum type,  void *cb )
201 {
202         SV *cmd;
203         ENTER_TLS_CONTEXT
204         dSP;
205
206         cmd = (SV*)cb;
207
208         ENTER;
209         SAVETMPS;
210         PUSHMARK(SP);
211         XPUSHs(sv_2mortal(newSViv(GLU_TESS_ERROR)));
212         XPUSHs(sv_2mortal(newSViv(type)));
213         PUTBACK;
214
215         call_sv(cmd,G_VOID);
216
217         FREETMPS;
218         LEAVE;
219         LEAVE_TLS_CONTEXT
220 }
221
222 void
223 sdl_perl_tess_edge_flag_callback ( GLenum flag,  void *cb )
224 {
225         SV *cmd;
226         ENTER_TLS_CONTEXT
227         dSP;
228
229         cmd = (SV*)cb;
230
231         ENTER;
232         SAVETMPS;
233         PUSHMARK(SP);
234         XPUSHs(sv_2mortal(newSViv(GLU_TESS_EDGE_FLAG)));
235         XPUSHs(sv_2mortal(newSViv(flag)));
236         PUTBACK;
237
238         call_sv(cmd,G_VOID);
239
240         FREETMPS;
241         LEAVE;
242         LEAVE_TLS_CONTEXT
243 }
244
245 void
246 sdl_perl_tess_vertex_callback ( double *vd,  void *cb )
247 {
248         SV *cmd;
249         ENTER_TLS_CONTEXT
250         dSP;
251
252         cmd = (SV*)cb;
253
254         ENTER;
255         SAVETMPS;
256         PUSHMARK(SP);
257         XPUSHs(sv_2mortal(newSViv(GLU_TESS_VERTEX)));
258         XPUSHs(sv_2mortal(newSVnv(vd[0])));
259         XPUSHs(sv_2mortal(newSVnv(vd[1])));
260         XPUSHs(sv_2mortal(newSVnv(vd[2])));
261         XPUSHs(sv_2mortal(newSVnv(vd[3])));
262         XPUSHs(sv_2mortal(newSVnv(vd[4])));
263         XPUSHs(sv_2mortal(newSVnv(vd[5])));
264         PUTBACK;
265
266         call_sv(cmd,G_VOID);
267
268         FREETMPS;
269         LEAVE;
270         LEAVE_TLS_CONTEXT
271 }
272
273 void
274 sdl_perl_tess_combine_callback ( GLdouble coords[3], double *vd[4], GLfloat weight[4], 
275         GLdouble **out, void *cb )
276 {
277         SV *cmd;
278         double *data;
279         int width;
280         ENTER_TLS_CONTEXT
281         dSP;
282
283         cmd = (SV*)cb;
284
285         ENTER;
286         SAVETMPS;
287         PUSHMARK(SP);
288         XPUSHs(sv_2mortal(newSViv(GLU_TESS_COMBINE)));
289         XPUSHs(sv_2mortal(newSVpvn((char*)coords,sizeof(GLdouble)*3)));
290         XPUSHs(sv_2mortal(newSVpvn((char*)vd,sizeof(GLdouble*)*4)));
291         XPUSHs(sv_2mortal(newSVpvn((char*)weight,sizeof(GLfloat)*4)));
292         PUTBACK;
293
294         if ( 1 != call_sv(cmd,G_SCALAR) ) {
295                 Perl_croak(aTHX_ "sdl_perl_tess_combine_callback failed");
296         }
297
298         data = (double*)POPp;
299         width = (int)POPi;
300         *out = (double*)malloc(sizeof(double)*width);
301         memcpy(*out,data,sizeof(double)*width);
302
303         FREETMPS;
304         LEAVE;
305         LEAVE_TLS_CONTEXT
306 }
307
308 MODULE = SDL::OpenGL            PACKAGE = SDL::OpenGL
309 PROTOTYPES : DISABLE
310
311 #ifdef HAVE_GL
312
313 void
314 glClearColor ( r, g, b, a)
315         double r
316         double g
317         double b
318         double a
319         CODE:
320                 glClearColor((GLfloat)r,(GLfloat)g,(GLfloat)b,(GLfloat)a);
321
322 void
323 glClearIndex ( index )
324         double index
325         CODE:
326                 glClearIndex(index);
327
328 void
329 glClearDepth ( depth )
330         double depth
331         CODE:
332                 glClearDepth(depth);
333
334 void
335 glClearStencil ( s )
336         int s
337         CODE:
338                 glClearStencil(s);
339
340 void
341 glClearAccum ( r, g, b, a )
342         double r
343         double g
344         double b
345         double a
346         CODE:
347                 glClearAccum((GLfloat)r,(GLfloat)g,(GLfloat)b,(GLfloat)a);
348
349 void
350 glClear ( m )
351         GLbitfield m
352         CODE:
353                 glClear(m);
354
355 void
356 glFlush ()
357         CODE:
358                 glFlush();
359
360 void
361 glFinish ()
362         CODE:
363                 glFinish();
364
365 void
366 glRect ( r )
367         SDL_Rect* r
368         CODE:
369                 glRecti(r->x,r->y,r->x+r->w,r->y+r->h);
370
371 void
372 glVertex ( x, y, ... )
373         double x
374         double y
375         CODE:
376                 double z,w;
377                 if ( items == 4 ) {
378                         w = SvNV(ST(3));
379                         z = SvNV(ST(2));
380                         glVertex4d(x,y,z,w);    
381                 } else if ( items == 3 ) {
382                         z = SvNV(ST(2));
383                         glVertex3d(x,y,z);      
384                 } else {
385                         glVertex2d(x,y);
386                 }
387                 
388 void
389 glBegin ( mode )
390         GLenum mode
391         CODE:
392                 glBegin(mode);
393
394 void
395 glEnd ()
396         CODE:
397                 glEnd();
398
399 void
400 glEnable ( cap )
401         GLenum cap
402         CODE:
403                 glEnable(cap);
404
405 void
406 glDisable ( cap )
407         GLenum cap
408         CODE:
409                 glDisable(cap);
410
411 void 
412 glGet ( param )
413         GLenum param
414     PPCODE:
415         switch (param) {
416         case GL_EDGE_FLAG_ARRAY:
417         case GL_MAP1_TEXTURE_COORD_1:
418         case GL_LIGHT_MODEL_TWO_SIDE:
419         case GL_INDEX_LOGIC_OP:
420         case GL_PACK_ALIGNMENT:
421         case GL_CLIP_PLANE4:
422         case GL_TEXTURE_GEN_S:
423         case GL_MAP1_VERTEX_3:
424         case GL_LIGHT6:
425         case GL_LIGHT0:
426         case GL_NORMAL_ARRAY:
427         case GL_EDGE_FLAG:
428         case GL_INDEX_ARRAY:
429         case GL_AUTO_NORMAL:
430         case GL_POLYGON_OFFSET_FILL:
431         case GL_MAP1_TEXTURE_COORD_4:
432         case GL_FOG:
433         case GL_LIGHT2:
434         case GL_UNPACK_SWAP_BYTES:
435         case GL_RGBA_MODE:
436         case GL_POLYGON_OFFSET_POINT:
437         case GL_POINT_SMOOTH:
438         case GL_ALPHA_TEST:
439         case GL_MAP2_TEXTURE_COORD_4:
440         case GL_COLOR_ARRAY:
441         case GL_POLYGON_OFFSET_LINE:
442         case GL_MAP2_NORMAL:
443         case GL_MAP1_INDEX:
444         case GL_PACK_LSB_FIRST:
445         case GL_MAP1_TEXTURE_COORD_2:
446         case GL_MAP2_VERTEX_3:
447         case GL_MAP2_TEXTURE_COORD_2:
448         case GL_CULL_FACE:
449         case GL_DOUBLEBUFFER:
450         case GL_UNPACK_LSB_FIRST:
451         case GL_TEXTURE_COORD_ARRAY:
452         case GL_LIGHT1:
453         case GL_TEXTURE_GEN_Q:
454         case GL_MAP_STENCIL:
455         case GL_TEXTURE_1D:
456         case GL_LIGHT4:
457         case GL_LIGHTING:
458         case GL_LIGHT7:
459         case GL_MAP1_NORMAL:
460         case GL_CLIP_PLANE0:
461         case GL_TEXTURE_GEN_R:
462         case GL_PACK_SWAP_BYTES:
463         case GL_DEPTH_WRITEMASK:
464         case GL_COLOR_LOGIC_OP:
465         case GL_CLIP_PLANE5:
466         case GL_NORMALIZE:
467         case GL_TEXTURE_2D:
468         case GL_CLIP_PLANE3:
469         case GL_COLOR_MATERIAL:
470         case GL_BLEND:
471         case GL_CLIP_PLANE2:
472         case GL_MAP1_VERTEX_4:
473         case GL_DITHER:
474         case GL_CLIP_PLANE1:
475         case GL_MAP2_INDEX:
476         case GL_POLYGON_SMOOTH:
477         case GL_STEREO:
478         case GL_MAP2_COLOR_4:
479         case GL_LIGHT3:
480         case GL_VERTEX_ARRAY:
481         case GL_MAP1_TEXTURE_COORD_3:
482         case GL_STENCIL_TEST:
483         case GL_MAP2_TEXTURE_COORD_3:
484         case GL_TEXTURE_GEN_T:
485         case GL_LIGHT_MODEL_LOCAL_VIEWER:
486         case GL_LINE_SMOOTH:
487         case GL_MAP1_COLOR_4:
488         case GL_MAP2_TEXTURE_COORD_1:
489         case GL_CURRENT_RASTER_POSITION_VALID:
490         case GL_INDEX_MODE:
491         case GL_SCISSOR_TEST:
492         case GL_MAP_COLOR:
493         case GL_POLYGON_STIPPLE:
494         case GL_LIGHT5:
495         case GL_DEPTH_TEST:
496         case GL_LINE_STIPPLE:
497         case GL_MAP2_VERTEX_4:
498         {
499             GLboolean ret[1];
500             int i;
501             glGetBooleanv(param, ret);
502
503             for (i = 0; i < 1; i++) {
504                 XPUSHs(sv_2mortal(newSViv(ret[i])));
505             }
506             break;
507         }
508         case GL_COLOR_WRITEMASK:
509         {
510             GLboolean ret[4];
511             int i;
512             glGetBooleanv(param, ret);
513
514             for (i = 0; i < 4; i++) {
515                 XPUSHs(sv_2mortal(newSViv(ret[i])));
516             }
517             break;
518         }
519         case GL_ZOOM_Y:
520         case GL_ALPHA_TEST_REF:
521         case GL_POINT_SIZE_GRANULARITY:
522         case GL_CURRENT_RASTER_DISTANCE:
523         case GL_ALPHA_SCALE:
524         case GL_RED_BIAS:
525         case GL_DEPTH_BIAS:
526         case GL_FOG_DENSITY:
527         case GL_GREEN_BIAS:
528         case GL_DEPTH_CLEAR_VALUE:
529         case GL_ALPHA_BIAS:
530         case GL_FOG_END:
531         case GL_GREEN_SCALE:
532         case GL_BLUE_BIAS:
533         case GL_DEPTH_SCALE:
534         case GL_POINT_SIZE:
535         case GL_POLYGON_OFFSET_FACTOR:
536         case GL_ZOOM_X:
537         case GL_FOG_START:
538         case GL_POLYGON_OFFSET_UNITS:
539         case GL_LINE_WIDTH:
540         case GL_LINE_WIDTH_GRANULARITY:
541         case GL_BLUE_SCALE:
542         case GL_RED_SCALE:
543         {
544             GLdouble ret[1];
545             int i;
546             glGetDoublev(param, ret);
547
548             for (i = 0; i < 1; i++) {
549                 XPUSHs(sv_2mortal(newSVnv(ret[i])));
550             }
551             break;
552         }
553         case GL_MODELVIEW_MATRIX:
554         case GL_TEXTURE_MATRIX:
555         case GL_PROJECTION_MATRIX:
556         {
557             GLdouble ret[16];
558             int i;
559             glGetDoublev(param, ret);
560
561             for (i = 0; i < 16; i++) {
562                 XPUSHs(sv_2mortal(newSVnv(ret[i])));
563             }
564             break;
565         }
566         case GL_POINT_SIZE_RANGE:
567         case GL_LINE_WIDTH_RANGE:
568         case GL_MAP1_GRID_DOMAIN:
569         case GL_DEPTH_RANGE:
570         {
571             GLdouble ret[2];
572             int i;
573             glGetDoublev(param, ret);
574
575             for (i = 0; i < 2; i++) {
576                 XPUSHs(sv_2mortal(newSVnv(ret[i])));
577             }
578             break;
579         }
580         case GL_CURRENT_NORMAL:
581         {
582             GLdouble ret[3];
583             int i;
584             glGetDoublev(param, ret);
585
586             for (i = 0; i < 3; i++) {
587                 XPUSHs(sv_2mortal(newSVnv(ret[i])));
588             }
589             break;
590         }
591         case GL_FOG_COLOR:
592         case GL_MAP2_GRID_DOMAIN:
593         case GL_CURRENT_RASTER_POSITION:
594         case GL_CURRENT_COLOR:
595         case GL_LIGHT_MODEL_AMBIENT:
596         case GL_CURRENT_RASTER_TEXTURE_COORDS:
597         case GL_TEXTURE_ENV_COLOR:
598         case GL_CURRENT_RASTER_COLOR:
599         case GL_CURRENT_TEXTURE_COORDS:
600         case GL_COLOR_CLEAR_VALUE:
601         case GL_ACCUM_CLEAR_VALUE:
602         {
603             GLdouble ret[4];
604             int i;
605             glGetDoublev(param, ret);
606
607             for (i = 0; i < 4; i++) {
608                 XPUSHs(sv_2mortal(newSVnv(ret[i])));
609             }
610             break;
611         }
612         case GL_CULL_FACE_MODE:
613         case GL_PIXEL_MAP_I_TO_A_SIZE:
614         case GL_PIXEL_MAP_A_TO_A_SIZE:
615         case GL_BLUE_BITS:
616         case GL_EDGE_FLAG_ARRAY_STRIDE:
617         case GL_RENDER_MODE:
618         case GL_FOG_MODE:
619         case GL_DEPTH_FUNC:
620         case GL_READ_BUFFER:
621         case GL_POINT_SMOOTH_HINT:
622         case GL_PACK_SKIP_PIXELS:
623         case GL_STENCIL_REF:
624         case GL_STENCIL_CLEAR_VALUE:
625         case GL_AUX_BUFFERS:
626         case GL_COLOR_MATERIAL_PARAMETER:
627         case GL_ACCUM_BLUE_BITS:
628         case GL_INDEX_SHIFT:
629         case GL_VERTEX_ARRAY_STRIDE:
630         case GL_STENCIL_PASS_DEPTH_PASS:
631         case GL_CLIENT_ATTRIB_STACK_DEPTH:
632         case GL_DRAW_BUFFER:
633         case GL_LINE_STIPPLE_REPEAT:
634         case GL_BLEND_SRC:
635         case GL_PIXEL_MAP_B_TO_B_SIZE:
636         case GL_MAX_PIXEL_MAP_TABLE:
637         case GL_MAX_TEXTURE_SIZE:
638         case GL_PIXEL_MAP_S_TO_S_SIZE:
639         case GL_LOGIC_OP_MODE:
640         case GL_DEPTH_BITS:
641         case GL_GREEN_BITS:
642         case GL_LINE_SMOOTH_HINT:
643         case GL_ALPHA_TEST_FUNC:
644         case GL_MAX_LIGHTS:
645         case GL_FOG_HINT:
646         case GL_MAX_NAME_STACK_DEPTH:
647         case GL_INDEX_ARRAY_TYPE:
648         case GL_TEXTURE_COORD_ARRAY_TYPE:
649         case GL_COLOR_ARRAY_TYPE:
650         case GL_MAX_LIST_NESTING:
651         case GL_STENCIL_WRITEMASK:
652         case GL_LIST_BASE:
653         case GL_ACCUM_ALPHA_BITS:
654         case GL_INDEX_ARRAY_STRIDE:
655         case GL_PIXEL_MAP_I_TO_B_SIZE:
656         case GL_INDEX_BITS:
657         case GL_STENCIL_FAIL:
658         case GL_UNPACK_ALIGNMENT:
659         case GL_STENCIL_PASS_DEPTH_FAIL:
660         case GL_ATTRIB_STACK_DEPTH:
661         case GL_PACK_SKIP_ROWS:
662         case GL_TEXTURE_STACK_DEPTH:
663         case GL_MATRIX_MODE:
664         case GL_COLOR_ARRAY_STRIDE:
665         case GL_LIST_MODE:
666         case GL_UNPACK_SKIP_PIXELS:
667         case GL_PIXEL_MAP_G_TO_G_SIZE:
668         case GL_VERTEX_ARRAY_TYPE:
669         case GL_RED_BITS:
670         case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
671         case GL_INDEX_CLEAR_VALUE:
672         case GL_PIXEL_MAP_I_TO_G_SIZE:
673         case GL_ALPHA_BITS:
674         case GL_PIXEL_MAP_I_TO_R_SIZE:
675         case GL_COLOR_ARRAY_SIZE:
676         case GL_TEXTURE_COORD_ARRAY_SIZE:
677         case GL_MAP1_GRID_SEGMENTS:
678         case GL_VERTEX_ARRAY_SIZE:
679         case GL_PIXEL_MAP_R_TO_R_SIZE:
680         case GL_TEXTURE_COORD_ARRAY_STRIDE:
681         case GL_MODELVIEW_STACK_DEPTH:
682         case GL_MAX_TEXTURE_STACK_DEPTH:
683         case GL_PIXEL_MAP_I_TO_I_SIZE:
684         case GL_FOG_INDEX:
685         case GL_INDEX_WRITEMASK:
686         case GL_PACK_ROW_LENGTH:
687         case GL_CURRENT_INDEX:
688         case GL_STENCIL_VALUE_MASK:
689         case GL_UNPACK_SKIP_ROWS:
690         case GL_MAX_PROJECTION_STACK_DEPTH:
691         case GL_LIST_INDEX:
692         case GL_STENCIL_FUNC:
693         case GL_INDEX_OFFSET:
694         case GL_UNPACK_ROW_LENGTH:
695         case GL_COLOR_MATERIAL_FACE:
696         case GL_NORMAL_ARRAY_TYPE:
697         case GL_STENCIL_BITS:
698         case GL_PROJECTION_STACK_DEPTH:
699         case GL_CURRENT_RASTER_INDEX:
700         case GL_SHADE_MODEL:
701         case GL_TEXTURE_ENV_MODE:
702         case GL_NORMAL_ARRAY_STRIDE:
703         case GL_PERSPECTIVE_CORRECTION_HINT:
704         case GL_MAX_CLIP_PLANES:
705         case GL_MAX_MODELVIEW_STACK_DEPTH:
706         case GL_SUBPIXEL_BITS:
707         case GL_ACCUM_RED_BITS:
708         case GL_BLEND_DST:
709         case GL_FRONT_FACE:
710         case GL_MAX_EVAL_ORDER:
711         case GL_LINE_STIPPLE_PATTERN:
712         case GL_NAME_STACK_DEPTH:
713         case GL_MAX_ATTRIB_STACK_DEPTH:
714         case GL_POLYGON_SMOOTH_HINT:
715         case GL_ACCUM_GREEN_BITS:
716         {
717             GLint ret[1];
718             int i;
719             glGetIntegerv(param, ret);
720
721             for (i = 0; i < 1; i++) {
722                 XPUSHs(sv_2mortal(newSViv(ret[i]))); 
723             }
724             break;
725         }
726         case GL_POLYGON_MODE:
727         case GL_MAX_VIEWPORT_DIMS:
728         case GL_MAP2_GRID_SEGMENTS:
729         {
730             GLint ret[2];
731             int i;
732             glGetIntegerv(param, ret);
733
734             for (i = 0; i < 2; i++) {
735                 XPUSHs(sv_2mortal(newSViv(ret[i]))); 
736             }
737             break;
738         }
739         case GL_SCISSOR_BOX:
740         case GL_VIEWPORT:
741         {
742             GLint ret[4];
743             int i;
744             glGetIntegerv(param, ret);
745
746             for (i = 0; i < 4; i++) {
747                 XPUSHs(sv_2mortal(newSViv(ret[i]))); 
748             }
749             break;
750         }
751         default:
752             croak("Unknown glGet parameter!");
753         }
754
755
756 Uint32
757 glIsEnabled ( cap )
758         Uint32 cap
759         CODE:
760                 RETVAL = glIsEnabled(cap);
761         OUTPUT:
762                 RETVAL
763
764 void
765 glPointSize ( size )
766         double size
767         CODE:
768                 glPointSize((GLfloat)size);
769
770 void
771 glLineWidth ( size )
772         double size
773         CODE:
774                 glLineWidth((GLfloat)size);
775
776 void
777 glLineStipple ( factor, pattern )
778         Sint32 factor
779         Uint16 pattern
780         CODE:
781                 glLineStipple(factor,pattern);
782
783 void
784 glPolygonMode ( face, mode )
785         GLenum face
786         GLenum mode
787         CODE:
788                 glPolygonMode(face,mode);
789
790 void
791 glFrontFace ( mode )
792         GLenum mode
793         CODE:
794                 glFrontFace(mode);
795
796 void
797 glCullFace ( mode )
798         GLenum mode
799         CODE:
800                 glCullFace(mode);
801
802 void
803 glPolygonStipple ( mask )
804         char *mask
805         CODE:
806                 glPolygonStipple(mask);
807
808 void
809 glEdgeFlag ( flag )
810         GLenum flag
811         CODE:
812                 glEdgeFlag(flag);
813
814 void
815 glNormal ( x, y, z )
816         double x
817         double y
818         double z
819         CODE:
820                 glNormal3d(x,y,z);
821
822 void
823 glEnableClientState ( array )
824         GLenum array
825         CODE:
826                 glEnableClientState(array);
827
828 void
829 glDisableClientState ( array )
830         GLenum array
831         CODE:
832                 glDisableClientState(array);
833
834 void
835 glVertexPointer ( size, type, stride, pointer)
836         int size
837         GLenum type
838         Uint32 stride
839         char *pointer
840         CODE:
841                 glVertexPointer(size,type,stride,pointer);
842
843 void
844 glColorPointer ( size, type, stride, pointer )
845         Sint32 size
846         GLenum type
847         Uint32 stride
848         char *pointer
849         CODE:
850                 glColorPointer(size,type,stride,pointer);
851
852 void
853 glNormalPointer ( type, stride, pointer )
854         GLenum type
855         Uint32 stride
856         char *pointer
857         CODE:
858                 glNormalPointer(type,stride,pointer);
859
860 void
861 glTexCoordPointer ( size, type, stride, pointer )
862         Sint32 size
863         GLenum type
864         Uint32 stride
865         char *pointer
866         CODE:
867                 glTexCoordPointer(size,type,stride,pointer);
868
869 void
870 glEdgeFlagPointer ( stride, pointer )
871         Uint32 stride
872         char *pointer
873         CODE:
874                 glEdgeFlagPointer(stride,pointer);
875
876 void
877 glArrayElement ( ith )
878         Uint32 ith
879         CODE:
880                 glArrayElement(ith);
881
882 void
883 glDrawElements ( mode, count, type, indices )
884         GLenum mode
885         Uint32 count
886         GLenum type
887         char *indices
888         CODE:
889                 glDrawElements( mode, count, type, indices);
890
891 #ifdef GL_VERSION_1_2
892
893 void
894 glDrawRangeElements ( mode, start, end, count, type, indices )
895         GLenum mode
896         Uint32 start
897         Uint32 end
898         Uint32 count
899         GLenum type
900         char *indices
901         CODE:
902                 glDrawRangeElements(mode,start,end,count,type,indices);
903
904 #endif // GL_VERSION_1_2
905
906 void
907 glDrawArrays ( mode, first, count )
908         GLenum mode
909         Uint32 first
910         Uint32 count
911         CODE:
912                 glDrawArrays(mode,first,count);
913
914 void
915 glInterleavedArrays ( format, stride, pointer )
916         GLenum format
917         Uint32 stride
918         char *pointer
919         CODE:
920                 glInterleavedArrays(format,stride,pointer);
921
922 void
923 glPushAttrib ( mask )
924         GLbitfield mask
925         CODE:
926                 glPushAttrib(mask);
927
928 void
929 glPopAttrib ()
930         CODE:
931                 glPopAttrib();
932
933 void
934 glPushClientAttrib ( mask )
935         GLbitfield mask
936         CODE:
937                 glPushClientAttrib(mask);
938
939 void
940 glPopClientAttrib ()
941         CODE:
942                 glPopClientAttrib();
943
944 void
945 glMatrixMode ( mode )
946         GLenum mode
947         CODE:
948                 glMatrixMode(mode);
949
950 void
951 glLoadIdentity ()
952         CODE:
953                 glLoadIdentity();
954
955 void
956 glLoadMatrix (  ... )
957         CODE:
958                 int i;
959                 double mat[16];
960                 for ( i = 0; i < 16; i++ ) {
961                         mat[i] = (i < items  && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 );
962                 }
963                 glLoadMatrixd(mat);
964
965 void
966 glMultMatrix ( ... )
967         CODE:
968                 int i;
969                 double mat[16];
970                 for ( i = 0; i < 16; i++ ) {
971                         mat[i] = (i < items  && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 );
972                 }
973                 glMultMatrixd(mat);
974
975 void
976 glTranslate ( x, y, z )
977         double x
978         double y
979         double z
980         CODE:
981                 glTranslated(x,y,z);
982
983 void
984 glRotate ( angle, x, y, z )
985         double angle
986         double x
987         double y
988         double z
989         CODE:
990                 glRotated(angle,x,y,z);
991
992 void
993 glScale ( x, y, z )
994         double x
995         double y
996         double z
997         CODE:
998                 glScaled(x,y,z);
999
1000 void
1001 glFrustum ( left, right, bottom, top, n, f )
1002         double left
1003         double right
1004         double bottom
1005         double top
1006         double n
1007         double f
1008         CODE:
1009                 glFrustum(left,right,bottom,top,n,f);
1010
1011 void
1012 glOrtho ( left, right, bottom, top, n, f )
1013         double left
1014         double right
1015         double bottom
1016         double top
1017         double n
1018         double f
1019         CODE:
1020                 glOrtho(left,right,bottom,top,n,f);
1021
1022 void
1023 glViewport ( x, y, width, height )
1024         Sint32 x
1025         Sint32 y
1026         Uint32 width
1027         Uint32 height
1028         CODE:
1029                 glViewport(x,y,width,height);
1030
1031 void
1032 glDepthRange ( n, f )
1033         double n
1034         double f
1035         CODE:
1036                 glDepthRange(n,f);
1037
1038 void
1039 glPushMatrix ()
1040         CODE:
1041                 glPushMatrix();
1042
1043 void
1044 glPopMatrix ()
1045         CODE:
1046                 glPopMatrix();
1047
1048 void
1049 glClipPlane ( plane, ... )
1050         GLenum plane
1051         CODE:
1052                 double v[4];
1053                 int i;
1054                 for (i = 0; i < 4; i++ ) {
1055                         v[i] = (i+1 < items && SvNOK(ST(i+1))) ? SvNV(ST(i+1)) : 0.0;
1056                 }
1057                 glClipPlane(plane,v);
1058         
1059 void
1060 glColor ( r, g, b, ... )
1061         double r        
1062         double g
1063         double b        
1064         CODE:
1065                 if ( items == 4 ) {
1066                         double a;
1067                         a = SvNV(ST(3));
1068                         glColor4d(r,g,b,a);
1069                 } else {
1070                         glColor3d(r,g,b);       
1071                 }
1072
1073 void
1074 glIndex ( c )
1075         Uint32 c
1076         CODE:
1077                 glIndexi(c);
1078
1079 void
1080 glShadeModel ( mode )
1081         GLenum mode
1082         CODE:
1083                 glShadeModel(mode);
1084
1085 void
1086 glLight ( light, name, ... )
1087         GLenum light
1088         GLenum name
1089         CODE:
1090                 int i;
1091                 if ( items == 6 ) {
1092                         float v[4];     
1093                         for ( i = 0; i < 4; i++ ) {
1094                                 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1095                         }
1096                         glLightfv(light,name,v);        
1097                 } else if ( items == 5 ) {
1098                         float v[3];
1099                         for ( i = 0; i < 3; i++ ) {
1100                                 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1101                         }
1102                         glLightfv(light,name,v);        
1103                 } else if ( items == 3 ) {
1104                         float v;
1105                         v = SvNV(ST(2));
1106                         glLightf(light,name,v);
1107                 } else {
1108                         Perl_croak(aTHX_ "SDL::OpenGL::Light invalid arguments");
1109                 }
1110
1111 void 
1112 glLightModel ( pname, ... )
1113         GLenum pname
1114         CODE:
1115                 GLfloat vec[4];
1116                 if ( pname == GL_LIGHT_MODEL_LOCAL_VIEWER ||
1117                         pname == GL_LIGHT_MODEL_TWO_SIDE ||
1118                         pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
1119                         glLightModelf(pname,SvNV(ST(1)));
1120                 } else if ( pname == GL_LIGHT_MODEL_AMBIENT) {
1121                         vec[0] = SvNV(ST(1));
1122                         vec[1] = SvNV(ST(2));
1123                         vec[2] = SvNV(ST(3));
1124                         vec[3] = SvNV(ST(4));
1125                         glLightModelfv(pname,vec);
1126                 } else {
1127                         Perl_croak(aTHX_ "SDL::OpenGL::glLightModel unknown model %d",pname);
1128                 }
1129
1130 void
1131 glMaterial ( face, name, ... )
1132         GLenum face
1133         GLenum name
1134         CODE:
1135                 int i;
1136                 if ( items == 6 ) {
1137                         float v[4];
1138                         for ( i = 0; i < 4; i++ ) {
1139                                 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1140                         }
1141                         glMaterialfv(face,name,v);
1142                 } else if ( items == 5 ) {
1143                         float v[3];
1144                         for ( i = 0; i < 4; i++ ) {
1145                                 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1146                         }
1147                         glMaterialfv(face,name,v);
1148                 } else if ( items == 3 ) {      
1149                         float v;
1150                         v = SvNV(ST(2));
1151                         glMaterialf(face,name,v);
1152                 } else {
1153                         Perl_croak(aTHX_ "SDL::OpenGL::Material invalid arguments");
1154                 }
1155
1156 void
1157 glColorMaterial ( face, mode )
1158         GLenum face
1159         GLenum mode
1160         CODE:
1161                 glColorMaterial(face,mode);
1162
1163 void
1164 glBlendFunc ( sfactor, dfactor )
1165         GLenum sfactor
1166         GLenum dfactor
1167         CODE:
1168                 glBlendFunc(sfactor,dfactor);
1169
1170
1171 void
1172 glHint ( target, hint )
1173         GLenum target
1174         GLenum hint
1175         CODE:
1176                 glHint(target,hint);    
1177
1178 void
1179 glFog ( name, ... )
1180         GLenum name
1181         CODE:
1182                 if ( items == 5 )  {
1183                         float v[4];
1184                         v[0] = SvNV(ST(1));     
1185                         v[1] = SvNV(ST(2));     
1186                         v[2] = SvNV(ST(3));     
1187                         v[3] = SvNV(ST(4));     
1188                         glFogfv(name,v);
1189                 } else if ( items == 2 ) {
1190                         float v;
1191                         v = SvNV(ST(1));
1192                         glFogf(name,v);
1193                 } else {
1194                         Perl_croak(aTHX_ "SDL::OpenGL::Material invalid arguments");
1195                 }
1196
1197 void
1198 glPolygonOffset ( factor, units )
1199         double factor
1200         double units
1201         CODE:
1202                 glPolygonOffset(factor,units);
1203
1204 Uint32
1205 glGenLists ( range )
1206         Uint32 range
1207         CODE:
1208                 RETVAL = glGenLists(range);
1209         OUTPUT:
1210                 RETVAL
1211
1212 void
1213 glNewList ( list, mode )
1214         Uint32 list
1215         GLenum mode
1216         CODE:
1217                 glNewList(list,mode);
1218
1219 void
1220 glEndList ()
1221         CODE:
1222                 glEndList();
1223
1224 void
1225 glDeleteLists ( base, count )
1226         Uint32 base
1227         Uint32 count
1228         CODE:
1229                 glDeleteLists(base, count);
1230
1231 void
1232 glCallList ( list )
1233         Uint32 list
1234         CODE:
1235                 glCallList(list);
1236
1237 Uint32
1238 glIsList ( list )
1239         Uint32 list
1240         CODE:
1241                 RETVAL = glIsList(list);
1242         OUTPUT:
1243                 RETVAL
1244
1245 void
1246 glListBase ( base )
1247         Uint32 base
1248         CODE:
1249                 glListBase(base);
1250
1251 void
1252 glCallLists ( ... )
1253         CODE:
1254                 int *i, j;      
1255                 if ( items > 0 ) {
1256                         i = (int*)safemalloc(sizeof(int)* (items));
1257                         for ( j = 0; j < items; j++ ) {
1258                                 i[j] = SvIV(ST(j));
1259                         } 
1260                 } else {
1261                         Perl_croak(aTHX_ "usage: SDL::OpenGL::CallLists(type,...)");
1262                 }
1263                 glCallLists(items, GL_INT, i);
1264                 safefree(i);
1265
1266 void
1267 glCallListsString ( string )
1268         SV* string
1269         CODE:
1270                 char *str;
1271                 STRLEN len;
1272                 str = SvPV(string,len);
1273                 glCallLists(len,GL_BYTE,str);
1274
1275 void
1276 glRasterPos ( x, y, z, ... )
1277         double x
1278         double y
1279         double z
1280         CODE:
1281                 if ( items == 4 ) {
1282                         double w = SvNV(ST(3));
1283                         glRasterPos4d(x,y,z,w);
1284                 } else {
1285                         glRasterPos3d(x,y,z);
1286                 }
1287
1288 void
1289 glBitmap ( width, height, x1, y1, x2, y2, data )
1290         Uint32 width
1291         Uint32 height
1292         double x1
1293         double y1
1294         double x2
1295         double y2
1296         char *data
1297         CODE:
1298                 glBitmap(width,height,x1,y1,x2,y2,data);
1299
1300 void
1301 glDrawPixels ( width, height, format, type, pixels )
1302         Uint32 width
1303         Uint32 height
1304         GLenum format
1305         GLenum type
1306         char *pixels
1307         CODE:
1308                 glDrawPixels(width,height,format,type,pixels);
1309
1310
1311 SV*
1312 glReadPixels ( x, y, width, height, format, type )
1313         Uint32 x
1314         Uint32 y
1315         Uint32 height
1316         Uint32 width
1317         GLenum format
1318         GLenum type
1319         CODE:
1320                 int len, size;
1321                 char *buf;
1322                 size = 1;       /* ALPHA, BLUE, GREEN or RED */
1323                 if (format == GL_BGR || format == GL_RGB) 
1324                         size = 3;
1325                 if (format == GL_BGRA || format == GL_RGBA) 
1326                         size = 4;
1327                 len = height * width * size;            /* in bytes */
1328                 RETVAL = newSV(len);                    /* alloc len+1 bytes */
1329                 SvPOK_on(RETVAL);                       /* make an PV */
1330                 buf = SvPVX(RETVAL);                    /* get ptr to buffer */
1331                 glReadPixels(x,y,width,height,format,type,buf);
1332                 SvCUR_set(RETVAL, len);                 /* set real length */
1333         OUTPUT:
1334                 RETVAL
1335                                                                                                                                                             
1336 AV*
1337 glReadPixel ( x, y )
1338         Uint32 x
1339         Uint32 y
1340         CODE:
1341                 int rgba[4];    /* r,g,b,a */
1342                 int i;
1343                 glReadPixels(x,y,1,1,GL_RGBA,GL_UNSIGNED_INT,rgba);
1344                 RETVAL = newAV();
1345                 for ( i = 0; i < 4; i++ ) {
1346                         av_push(RETVAL,newSViv(rgba[i]));
1347                 }
1348         OUTPUT:
1349                 RETVAL
1350
1351 void
1352 glCopyPixels ( x, y, width, height, buffer )
1353         Sint32 x
1354         Sint32 y
1355         Uint32 width
1356         Uint32 height
1357         GLenum buffer
1358         CODE:
1359                 glCopyPixels(x,y,width,height,buffer);
1360
1361 void
1362 glPixelStore ( name, param )
1363         Sint32 name
1364         double param
1365         CODE:
1366                 glPixelStorei(name,param);
1367
1368 void
1369 glPixelTransfer ( name, ... )
1370         GLenum name
1371         CODE:
1372                 switch ( name ) {
1373                         case GL_MAP_COLOR:
1374                         case GL_MAP_STENCIL:
1375                         case GL_INDEX_SHIFT:
1376                         case GL_INDEX_OFFSET:
1377                                 glPixelTransferi(name,SvIV(ST(1)));
1378                                 break;
1379                         default:
1380                                 glPixelTransferf(name,SvNV(ST(1)));
1381                                 break;
1382                 }
1383
1384 void
1385 glPixelMap ( type, map, mapsize, values )
1386         GLenum type
1387         GLenum map
1388         Sint32 mapsize
1389         char *values
1390         CODE:
1391                 switch (type) {
1392                         case GL_UNSIGNED_INT: 
1393                                 glPixelMapuiv(map,mapsize,(GLint*)values);
1394                                 break;
1395                         case GL_UNSIGNED_SHORT:
1396                                 glPixelMapusv(map,mapsize,(GLushort*)values);
1397                                 break;
1398                         case GL_FLOAT:
1399                                 glPixelMapfv(map,mapsize,(GLfloat*)values);
1400                                 break;
1401                 }
1402                 
1403 void
1404 glPixelZoom ( zoomx, zoomy )
1405         double zoomx
1406         double zoomy
1407         CODE:
1408                 glPixelZoom(zoomx,zoomy);
1409
1410 #ifdef GL_VERSION_1_3
1411
1412 void
1413 glColorTable ( target, internalFormat, width, format, type, data )
1414         GLenum target 
1415         GLenum internalFormat
1416         Uint32 width
1417         GLenum format
1418         GLenum type
1419         char *data
1420         CODE:
1421                 glColorTable(target,internalFormat,width,format,type,data);
1422
1423 void
1424 glColorTableParameter ( target, name, r, g, b, a)
1425         GLenum target
1426         GLenum name
1427         double r
1428         double g
1429         double b
1430         double a
1431         CODE:
1432                 GLfloat vec[4];
1433                 vec[0] = r;
1434                 vec[1] = g;
1435                 vec[2] = b;
1436                 vec[3] = a;
1437                 glColorTableParameterfv(target,name,vec);
1438
1439 void
1440 glCopyColorTable ( target, internalFormat, x, y, width )
1441         GLenum target
1442         GLenum internalFormat
1443         Sint32 x
1444         Sint32 y
1445         Uint32 width
1446         CODE:
1447                 glCopyColorTable(target,internalFormat,x,y,width);
1448
1449 void
1450 glColorSubTable ( target, start, count, format, type, data )
1451         Uint32 target
1452         Uint32 start
1453         Uint32 count
1454         Uint32 format
1455         Uint32 type
1456         char *data
1457         CODE:
1458                 glColorSubTable(target,start,count,format,type,data);
1459
1460 void
1461 glCopyColorSubTable ( target, start, x, y, count )
1462         Uint32 target
1463         Uint32 start
1464         Sint32 x
1465         Sint32 y
1466         Uint32 count
1467         CODE:
1468                 glCopyColorSubTable(target,start,x,y,count);
1469
1470 void
1471 glConvolutionFilter2D ( target, internalFormat, width, height, format, type, image )
1472         Uint32 target
1473         Uint32 internalFormat
1474         Uint32 width
1475         Uint32 height
1476         Uint32 format
1477         Uint32 type
1478         char *image
1479         CODE:
1480                 glConvolutionFilter2D(target,internalFormat,width,height,format,type,image);
1481
1482 void
1483 glCopyConvolutionFilter2D ( target, internalFormat, x, y, width, height )
1484         Uint32 target
1485         Uint32 internalFormat
1486         Sint32 x
1487         Sint32 y
1488         Uint32 width
1489         Uint32 height
1490         CODE:
1491                 glCopyConvolutionFilter2D(target,internalFormat,x,y,width,height);
1492
1493 void
1494 glSeparableFilter2D ( target, internalFormat, width, height, format, type, row, column )
1495         Uint32 target
1496         Uint32 internalFormat
1497         Uint32 width
1498         Uint32 height
1499         Uint32 format
1500         Uint32 type
1501         char *row
1502         char *column
1503         CODE:
1504                 glSeparableFilter2D(target,internalFormat,width,height,format,type,row,column);
1505
1506 void
1507 glConvolutionFilter1D ( target, internalFormat, width, format, type, image )
1508         Uint32 target
1509         Uint32 internalFormat
1510         Uint32 width
1511         Uint32 format
1512         Uint32 type
1513         char *image
1514         CODE:
1515                 glConvolutionFilter1D(target,internalFormat,width,format,type,image);
1516
1517 void
1518 glCopyConvolutionFilter1D ( target, internalFormat, x, y, width )
1519         Uint32 target
1520         Uint32 internalFormat
1521         Sint32 x
1522         Sint32 y
1523         Uint32 width
1524         CODE:
1525                 glCopyConvolutionFilter1D(target,internalFormat,x,y,width);
1526
1527 void
1528 glConvolutionParameter ( target, pname, ... )
1529         Uint32 target
1530         Uint32 pname
1531         CODE:
1532                 Uint32 pi;
1533                 GLfloat pv[4];
1534                 switch(pname) { 
1535                 case GL_CONVOLUTION_BORDER_MODE:
1536                         if ( items != 3 ) 
1537                                 Perl_croak(aTHX_ "Usage: ConvolutionParameter(target,pname,...)");
1538                         pi = SvIV(ST(2));
1539                         glConvolutionParameteri(target,pname,pi);
1540                         break;
1541                 case GL_CONVOLUTION_FILTER_SCALE:
1542                 case GL_CONVOLUTION_FILTER_BIAS:
1543                         if ( items != 6 ) 
1544                                 Perl_croak(aTHX_ "Usage: ConvolutionParameter(target,pname,...)");
1545                         pv[0] = (GLfloat)SvNV(ST(2));
1546                         pv[1] = (GLfloat)SvNV(ST(3));
1547                         pv[2] = (GLfloat)SvNV(ST(4));
1548                         pv[3] = (GLfloat)SvNV(ST(5));
1549                         glConvolutionParameterfv(target,pname,pv);
1550                         break;
1551                 default:
1552                         Perl_croak(aTHX_ "ConvolutionParameter invalid parameter");
1553                         break;
1554                 }
1555
1556 void 
1557 glHistogram ( target, width, internalFormat, sink )
1558         Uint32 target
1559         Uint32 width
1560         Uint32 internalFormat
1561         GLboolean sink
1562         CODE:
1563                 glHistogram(target,width,internalFormat,sink);
1564
1565 void
1566 glGetHistogram ( target, reset, format, type, values )
1567         Uint32 target 
1568         GLboolean reset
1569         Uint32 format
1570         Uint32 type
1571         char *values
1572         CODE:
1573                 glGetHistogram(target,reset,format,type,values);
1574
1575 void
1576 glResetHistogram ( target )
1577         Uint32 target
1578         CODE:
1579                 glResetHistogram(target);
1580
1581 void
1582 glMinmax ( target, internalFormat, sink )
1583         Uint32 target
1584         Uint32 internalFormat
1585         GLboolean sink
1586         CODE:
1587                 glMinmax(target,internalFormat,sink);
1588
1589 void
1590 glGetMinmax ( target, reset, format, type, values )
1591         Uint32 target
1592         GLboolean reset
1593         Uint32 format
1594         Uint32 type
1595         char *values
1596         CODE:
1597                 glGetMinmax(target,reset,format,type,values);
1598
1599 void
1600 glResetMinmax ( target )
1601         Uint32 target
1602         CODE:
1603                 glResetMinmax(target);
1604
1605 void
1606 glBlendEquation ( mode )
1607         Uint32 mode
1608         CODE:
1609                 glBlendEquation(mode);
1610
1611 #endif // GL_VERSION_1_3
1612
1613 void
1614 glTexImage2D ( target, level, internalFormat, width, height, border, format, type, data )
1615         GLenum target
1616         Sint32 level
1617         Sint32 internalFormat
1618         Uint32 width
1619         Uint32 height
1620         Sint32 border
1621         GLenum format
1622         GLenum type
1623         char *data
1624         CODE:
1625                 glTexImage2D(target,level,internalFormat,width,height,border,format,type,data);
1626         
1627 void
1628 glCopyTexImage2D ( target, level, internalFormat, x, y, width, height, border )
1629         GLenum target
1630         Sint32 level
1631         Sint32 internalFormat
1632         Sint32 x
1633         Sint32 y
1634         Uint32 width
1635         Uint32 height
1636         Sint32 border
1637         CODE:
1638                 glCopyTexImage2D(target,level,internalFormat,x,y,width,height,border);
1639
1640 void
1641 glTexSubImage2D ( target, level, xoffset, yoffset, width, height, format, type, data )
1642         GLenum target
1643         Sint32 level
1644         Sint32 xoffset
1645         Sint32 yoffset
1646         Uint32 width
1647         Uint32 height
1648         GLenum format
1649         GLenum type
1650         char *data      
1651         CODE:
1652                 glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,data);
1653
1654 void
1655 glCopyTexSubImage2D ( target, level, xoffset, yoffset, x, y, width, height )
1656         GLenum target
1657         Sint32 level
1658         Sint32 xoffset
1659         Sint32 yoffset
1660         Sint32 x
1661         Sint32 y
1662         Uint32 width
1663         Uint32 height
1664         CODE:
1665                 glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
1666
1667 void
1668 glTexImage1D ( target, level, internalFormat, width, border, format, type, data )
1669         GLenum target
1670         Sint32 level
1671         Sint32 internalFormat
1672         Uint32 width
1673         Sint32 border
1674         GLenum format
1675         GLenum type
1676         char *data      
1677         CODE:
1678                 glTexImage1D(target,level,internalFormat,width,border,format,type,data);        
1679
1680 void
1681 glTexSubImage1D ( target, level, xoffset, width, format, type, data )
1682         GLenum target
1683         Sint32 level
1684         Sint32 xoffset 
1685         Uint32 width
1686         GLenum format
1687         GLenum type
1688         char *data      
1689         CODE:
1690                 glTexSubImage1D(target,level,xoffset,width,format,type,data);
1691
1692 void
1693 glCopyTexImage1D ( target, level, internalFormat, x, y, width, border )
1694         GLenum target
1695         Sint32 level
1696         Sint32 internalFormat
1697         Sint32 x
1698         Sint32 y
1699         Uint32 width
1700         Sint32 border
1701         CODE:
1702                 glCopyTexImage1D(target,level,internalFormat,x,y,width,border);
1703
1704 void
1705 glCopyTexSubImage1D ( target, level, xoffset, x, y, width )
1706         GLenum target
1707         Sint32 level
1708         Sint32 xoffset
1709         Sint32 x
1710         Sint32 y
1711         Uint32 width
1712         CODE:
1713                 glCopyTexSubImage1D(target,level,xoffset,x,y,width);
1714
1715 #ifdef GL_VERSION_1_3
1716
1717 void
1718 glTexImage3D ( target, level, internalFormat, width, height, depth, border, format, type, data )
1719         GLenum target
1720         Sint32 level
1721         Sint32 internalFormat
1722         Uint32 width
1723         Uint32 height
1724         Uint32 depth
1725         Sint32 border
1726         GLenum format
1727         GLenum type
1728         char *data
1729         CODE:
1730                 glTexImage3D(target,level,internalFormat,width,height,depth,border,format,type,data);
1731
1732 void
1733 glTexSubImage3D ( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data )
1734         GLenum target
1735         Sint32 level
1736         Sint32 xoffset
1737         Sint32 yoffset
1738         Sint32 zoffset
1739         Uint32 width
1740         Uint32 height
1741         Uint32 depth
1742         GLenum format
1743         GLenum type
1744         char *data
1745         CODE:
1746                 glTexSubImage3D(target,level,xoffset,yoffset,zoffset,
1747                         width,height,depth,format,type,data);
1748
1749 void
1750 glCopyTexSubImage3D ( target, level, xoffset, yoffset, zoffset, x, y, width, height )
1751         GLenum target
1752         Sint32 level
1753         Sint32 xoffset
1754         Sint32 yoffset
1755         Sint32 zoffset
1756         Sint32 x
1757         Sint32 y
1758         Uint32 width
1759         Uint32 height
1760         CODE:
1761                 glCopyTexSubImage3D(target,level,xoffset,yoffset,zoffset,x,y,width,height);
1762
1763 #endif // GL_VERSION_1_3
1764
1765 AV*
1766 glGenTextures ( n )
1767         Uint32 n;
1768         CODE:
1769                 GLsizei i;
1770                 GLuint* names;
1771                 names = (GLuint*)safemalloc(sizeof(GLuint)*n);
1772                 RETVAL = newAV();
1773                 glGenTextures(n,names);
1774                 for ( i = 0; i < n; i++ ) {
1775                         av_push(RETVAL,newSViv(names[i]));
1776                 }
1777                 safefree(names);
1778         OUTPUT:
1779                 RETVAL
1780
1781 GLboolean
1782 glIsTexture ( texture )
1783         Uint32 texture
1784         CODE:
1785                 RETVAL = glIsTexture(texture);
1786         OUTPUT:
1787                 RETVAL
1788
1789 void
1790 glBindTexture ( target, texture )
1791         GLenum target
1792         Uint32 texture
1793         CODE:
1794                 glBindTexture(target,texture);
1795
1796 void
1797 glDeleteTextures ( ... )
1798         CODE:
1799                 GLuint* textures;
1800                 int i;
1801                 textures = (GLuint*)safemalloc(sizeof(GLuint) * items);
1802                 if ( textures ) {
1803                         for ( i = 0; i < items; i++ ) {
1804                                 textures[i] = SvIV(ST(i));      
1805                         }
1806                 }
1807                 glDeleteTextures(items,textures);
1808                 safefree(textures);
1809                          
1810 AV*
1811 glAreTexturesResident ( ... )
1812         CODE:
1813                 GLuint* textures;
1814                 GLboolean *homes;
1815                 int i;
1816                 RETVAL = newAV();
1817                 textures = (GLuint*)safemalloc(sizeof(GLuint) * items);
1818                 homes = (GLboolean*)safemalloc(sizeof(GLboolean) * items);
1819                 if ( textures ) {
1820                         for ( i = 0; i < items; i++ ) {
1821                                 textures[i] = SvIV(ST(i));      
1822                         }
1823                 }
1824                 if ( GL_FALSE != glAreTexturesResident(items,textures,homes)) {
1825                         for (i = 0; i < items; i++ ) {
1826                                 av_push(RETVAL,newSViv(homes[i]));      
1827                         }
1828                 }
1829                 safefree(homes);
1830                 safefree(textures);
1831         OUTPUT:
1832                 RETVAL
1833
1834 void
1835 glPrioritizeTextures ( n, names, priorities )
1836         Uint32 n
1837         char *names
1838         char *priorities
1839         CODE:
1840                 glPrioritizeTextures(n,(GLuint*)names,(const GLclampf *)priorities);
1841
1842 void
1843 glTexEnv ( target, name, ... )
1844         GLenum target
1845         GLenum name
1846         CODE:
1847                 float pv[4];
1848                 GLint p;        
1849                 switch(name) {
1850                         case GL_TEXTURE_ENV_MODE:
1851                                 p = SvIV(ST(2));
1852                                 glTexEnvi(target,name,p);       
1853                                 break;
1854                         case GL_TEXTURE_ENV_COLOR:
1855                                 pv[0] = SvNV(ST(2));
1856                                 pv[1] = SvNV(ST(3));
1857                                 pv[2] = SvNV(ST(4));
1858                                 pv[3] = SvNV(ST(5));
1859                                 glTexEnvfv(target,name,pv);
1860                                 break;
1861                 }
1862
1863 void
1864 glTexCoord ( ... )
1865         CODE:
1866                 double s,t,r,q;
1867                 if ( items < 1 || items > 4 ) 
1868                         Perl_croak (aTHX_ "usage: SDL::OpenGL::TexCoord(s,[t,[r,[q]]])");
1869                 s = t = r = 0.0;
1870                 q = 1.0;
1871                 switch(items) {
1872                         case 4:
1873                                 q = SvNV(ST(3)); 
1874                         case 3:
1875                                 r = SvNV(ST(2)); 
1876                         case 2:
1877                                 t = SvNV(ST(1)); 
1878                         case 1:
1879                                 s = SvNV(ST(0));        
1880                 }
1881                 glTexCoord4d(s,t,r,q);
1882
1883 void
1884 glTexParameter ( target, name, ... )
1885         GLenum target
1886         GLenum name
1887         CODE:
1888                 GLfloat pv[4];
1889                 GLint p;
1890                 switch (name) {
1891                         case GL_TEXTURE_BORDER_COLOR:
1892                                 pv[0] = SvNV(ST(2));
1893                                 pv[1] = SvNV(ST(3));
1894                                 pv[2] = SvNV(ST(4));
1895                                 pv[3] = SvNV(ST(5));
1896                                 glTexParameterfv(target,name,pv);
1897                                 break;
1898                         case GL_TEXTURE_PRIORITY:
1899                         case GL_TEXTURE_MIN_LOD:
1900                         case GL_TEXTURE_MAX_LOD:
1901                                 pv[0] = SvNV(ST(2));
1902                                 glTexParameterf(target,name,pv[0]);     
1903                                 break;
1904                         case GL_TEXTURE_BASE_LEVEL:
1905                         case GL_TEXTURE_MAX_LEVEL:
1906                         default:
1907                                 p = SvIV(ST(2));        
1908                                 glTexParameteri(target,name,p);
1909                                 break;
1910                 }
1911
1912 void
1913 glTexGen ( coord, name, ... )
1914         GLenum coord
1915         GLenum name     
1916         CODE:
1917                 GLdouble *pv;
1918                 GLint p;
1919                 int i;
1920                 switch (name) {
1921                         case GL_TEXTURE_GEN_MODE:
1922                                 p = SvIV(ST(2));
1923                                 glTexGeni(coord,name,p);
1924                                 break;
1925                         default:
1926                                 if ( items == 2 ) 
1927                                         Perl_croak(aTHX_  "usage: glTexGen(coord,name,...)");
1928                                 pv = (GLdouble*)safemalloc(sizeof(GLdouble)*(items-2));
1929                                 for ( i = 0; i < items - 2; i++ ) {
1930                                         pv[i] = SvNV(ST(i+2));  
1931                                 }
1932                                 glTexGendv(coord,name,pv);      
1933                                 safefree(pv);
1934                                 break;
1935                 }
1936
1937 #ifdef GL_VERSION_1_3
1938
1939 void
1940 glActiveTextureARB ( texUnit )
1941         GLenum texUnit
1942         CODE:
1943                 glActiveTextureARB(texUnit);
1944                                 
1945 void
1946 glMultiTexCoord ( texUnit,  ... )
1947         Uint32 texUnit
1948         CODE:
1949                 double s,t,r,q;
1950                 if ( items < 2 || items > 5 ) 
1951                         Perl_croak (aTHX_ "usage: SDL::OpenGL::MultiTexCoord(tex,s,[t,[r,[q]]])");
1952                 s = t = r = 0.0;
1953                 q = 1.0;
1954                 switch(items) {
1955                         case 5:
1956                                 q = SvNV(ST(3)); 
1957                         case 4:
1958                                 r = SvNV(ST(2)); 
1959                         case 3:
1960                                 t = SvNV(ST(1)); 
1961                         case 2:
1962                                 s = SvNV(ST(0));        
1963                 }
1964                 glMultiTexCoord4dARB(texUnit,s,t,r,q);
1965
1966 #endif // GL_VERSION_1_3
1967
1968 void
1969 glDrawBuffer ( mode )
1970         GLenum mode
1971         CODE:
1972                 glDrawBuffer(mode);
1973
1974 void
1975 glReadBuffer ( mode )
1976         GLenum mode
1977         CODE:
1978                 glReadBuffer(mode);
1979
1980 void
1981 glIndexMask ( mask )
1982         Uint32 mask
1983         CODE:
1984                 glIndexMask(mask);
1985
1986 void
1987 glColorMask ( red, green, blue, alpha )
1988         GLboolean red
1989         GLboolean green 
1990         GLboolean blue 
1991         GLboolean alpha 
1992         CODE:
1993                 glColorMask(red,green,blue,alpha);
1994
1995 void
1996 glDepthMask ( flag )
1997         GLboolean flag
1998         CODE:
1999                 glDepthMask(flag);
2000
2001 void
2002 glStencilMask ( mask )
2003         Uint32 mask
2004         CODE:
2005                 glStencilMask(mask);
2006
2007 void
2008 glScissor ( x , y, width, height )
2009         Sint32 x
2010         Sint32 y
2011         Uint32 width
2012         Uint32 height 
2013         CODE:
2014                 glScissor(x,y,width,height);
2015
2016 void
2017 glAlphaFunc ( func, ref )
2018         GLenum func
2019         double ref
2020         CODE:
2021                 glAlphaFunc(func,ref);
2022
2023 void
2024 glStencilFunc ( func, ref, mask )
2025         GLenum func
2026         Sint32 ref
2027         Uint32 mask
2028         CODE:
2029                 glStencilFunc(func,ref,mask);
2030
2031 void
2032 glStencilOp ( fail, zfail, zpass )
2033         GLenum fail
2034         GLenum zfail
2035         GLenum zpass
2036         CODE:
2037                 glStencilOp(fail,zfail,zpass);
2038
2039 void
2040 glDepthFunc ( func )
2041         GLenum func
2042         CODE:
2043                 glDepthFunc(func);
2044
2045 void
2046 glLogicOp ( opcode )
2047         GLenum opcode
2048         CODE:
2049                 glLogicOp(opcode);
2050
2051 void
2052 glAccum ( op, value )
2053         GLenum op
2054         double value
2055         CODE:
2056                 glAccum(op,value);
2057
2058 void
2059 glMap1 ( target, u1, u2, stride, order, points )
2060         GLenum target
2061         double u1
2062         double u2
2063         Sint32 stride
2064         Sint32 order
2065         char *points
2066         CODE:
2067                 glMap1d(target,u1,u2,stride,order,(double*)points);
2068
2069 void
2070 glEvalCoord1 ( u )
2071         double u
2072         CODE:
2073                 glEvalCoord1d(u);       
2074
2075 void
2076 glMapGrid1 ( n, u1, u2 )
2077         Sint32 n
2078         double u1
2079         double u2
2080         CODE:
2081                 glMapGrid1d(n,u1,u2);
2082
2083 void
2084 glEvalMesh1 ( mode, p1, p2 )
2085         GLenum mode
2086         Sint32 p1
2087         Sint32 p2
2088         CODE:
2089                 glEvalMesh1(mode,p1,p2);
2090
2091 void
2092 glMap2 ( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points )
2093         GLenum target
2094         double u1
2095         double u2
2096         Sint32 ustride
2097         Sint32 uorder
2098         double v1
2099         double v2
2100         Sint32 vstride
2101         Sint32 vorder
2102         char *points
2103         CODE:
2104                 glMap2d(target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,(double*)points);
2105
2106 void
2107 glEvalCoord2 ( u, v )
2108         double u
2109         double v
2110         CODE:
2111                 glEvalCoord2d(u,v);
2112
2113 void
2114 glMapGrid2 ( nu, u1, u2, nv, v1, v2 )
2115         Sint32 nu
2116         double u1
2117         double u2
2118         Sint32 nv
2119         double v1
2120         double v2
2121         CODE:
2122                 glMapGrid2d(nu,u1,u2,nv,v1,v2);
2123
2124 void
2125 glEvalMesh2 ( mode, i1, i2, j1, j2 )
2126         GLenum mode
2127         Sint32 i1
2128         Sint32 i2
2129         Sint32 j1
2130         Sint32 j2
2131         CODE:
2132                 glEvalMesh2(mode,i1,i2,j1,j2);
2133
2134 GLenum
2135 glGetError ( )
2136         CODE:
2137                 RETVAL = glGetError();
2138         OUTPUT:
2139                 RETVAL
2140
2141 GLint
2142 glRenderMode ( mode )
2143         GLenum mode
2144         CODE:
2145                 RETVAL = glRenderMode( mode );
2146         OUTPUT:
2147                 RETVAL
2148
2149 void
2150 glInitNames ( )
2151         CODE:
2152                 glInitNames();
2153
2154 void
2155 glPushName ( name )
2156         GLuint name
2157         CODE:
2158                 glPushName(name);
2159
2160 void
2161 glPopName ( )
2162         CODE:
2163                 glPopName();            
2164
2165 void
2166 glLoadName ( name )
2167         GLuint name
2168         CODE:
2169                 glLoadName(name);
2170         
2171 void
2172 glFeedbackBuffer ( size, type, buffer )
2173         GLuint size
2174         GLenum type
2175         float* buffer
2176         CODE:
2177                 glFeedbackBuffer(size,type,buffer);             
2178
2179 void
2180 glPassThrough ( token )
2181         GLfloat token
2182         CODE:
2183                 glPassThrough(token);
2184
2185
2186 #endif
2187
2188 #ifdef HAVE_GLU
2189
2190 void
2191 gluLookAt ( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz )
2192         double eyex
2193         double eyey
2194         double eyez
2195         double centerx
2196         double centery
2197         double centerz
2198         double upx
2199         double upy
2200         double upz
2201         CODE:
2202                 gluLookAt(eyex,eyey,eyez,centerx,centery,centerz,upx,upy,upz);
2203
2204 void
2205 gluPerspective ( fovy, aspect, n, f )
2206         double fovy
2207         double aspect
2208         double n
2209         double f
2210         CODE:
2211                 gluPerspective(fovy,aspect,n,f);
2212
2213 void
2214 gluPickMatrix ( x, y, delx, dely, viewport )
2215         double x
2216         double y
2217         double delx
2218         double dely
2219         GLint* viewport
2220         CODE:
2221                 gluPickMatrix(x,y,delx,dely,viewport);
2222
2223 void
2224 gluOrtho2D ( left, right, bottom, top )
2225         double left
2226         double right
2227         double bottom
2228         double top
2229         CODE:
2230                 gluOrtho2D(left,right,bottom,top);
2231
2232 int
2233 gluScaleImage ( format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout )
2234         GLenum format
2235         Uint32 widthin
2236         Uint32 heightin
2237         GLenum typein
2238         char *datain
2239         Uint32 widthout
2240         Uint32 heightout
2241         GLenum typeout
2242         char *dataout
2243         CODE:
2244                 RETVAL = gluScaleImage(format,widthin,heightin,typein,datain,
2245                                 widthout,heightout,typeout,dataout);
2246         OUTPUT:
2247                 RETVAL
2248
2249 int
2250 gluBuild1DMipmaps ( target, internalFormat, width, format, type, data )
2251         GLenum target
2252         Sint32 internalFormat
2253         Uint32 width
2254         GLenum format
2255         GLenum type
2256         char *data
2257         CODE:
2258                 RETVAL = gluBuild1DMipmaps(target,internalFormat,width,format,type,data);
2259         OUTPUT:
2260                 RETVAL
2261
2262 int
2263 gluBuild2DMipmaps ( target, internalFormat, width, height, format, type, data )
2264         GLenum target
2265         Sint32 internalFormat
2266         Uint32 width
2267         Uint32 height 
2268         GLenum format
2269         GLenum type
2270         char *data
2271         CODE:
2272                 RETVAL = gluBuild2DMipmaps(target,internalFormat,width,height,format,type,data);
2273         OUTPUT: 
2274                 RETVAL
2275
2276
2277 #if HAVE_GLU_VERSION >= 12
2278 int
2279 gluBuild3DMipmaps ( target, internalFormat, width, height, depth, format, type, data )
2280         GLenum target
2281         Sint32 internalFormat
2282         Uint32 width
2283         Uint32 height 
2284         Uint32 depth 
2285         GLenum format
2286         GLenum type
2287         char *data
2288         CODE:
2289                 RETVAL = gluBuild3DMipmaps(target,internalFormat,width,height,depth,
2290                                 format,type,data);
2291         OUTPUT: 
2292                 RETVAL
2293
2294 #else
2295 void
2296 gluBuild3DMipmaps ( )
2297         CODE:
2298                 Perl_croak (aTHX_ "SDL::OpenGL::Build3DMipmaps requires GLU 1.2");
2299
2300 #endif
2301
2302 #if HAVE_GLU_VERSION >= 12
2303 int
2304 gluBuild1DMipmapLevels ( target, internalFormat, width, format, type, level, base, max, data )
2305         GLenum target
2306         Sint32 internalFormat
2307         Uint32 width
2308         GLenum format
2309         GLenum type
2310         Sint32 level
2311         Sint32 base
2312         Sint32 max
2313         char *data
2314         CODE:
2315                 RETVAL = gluBuild1DMipmapLevels(target,internalFormat,width,
2316                                 format,type,level,base,max,data);
2317         OUTPUT:
2318                 RETVAL
2319
2320 #else
2321 void
2322 gluBuild1DMipmapLevels ()
2323         CODE:
2324                 Perl_croak(aTHX_ "SDL::OpenGL::Build1DMipmapLevels requires GLU 1.2");          
2325         
2326 #endif
2327
2328 #if HAVE_GLU_VERSION >= 12
2329 int
2330 gluBuild2DMipmapLevels ( target, internalFormat, width, height, format, type, level, base, max, data )
2331         GLenum target
2332         Sint32 internalFormat
2333         Uint32 width
2334         Uint32 height 
2335         GLenum format
2336         GLenum type
2337         Sint32 level
2338         Sint32 base
2339         Sint32 max
2340         char *data
2341         CODE:
2342                 RETVAL = gluBuild2DMipmapLevels(target,internalFormat,width,height,
2343                                 format,type,level,base,max,data);
2344         OUTPUT:
2345                 RETVAL
2346
2347 #else
2348 void
2349 gluBuild2DMipmapLevels ()
2350         CODE:
2351                 Perl_croak(aTHX_ "SDL::OpenGL::Build2DMipmapLevels requires GLU 1.2");          
2352
2353 #endif
2354
2355 #if HAVE_GLU_VERSION >= 12
2356 int
2357 gluBuild3DMipmapLevels ( target, internalFormat, width, height, depth, format, type, level, base, max, data )
2358         GLenum target
2359         Sint32 internalFormat
2360         Uint32 width
2361         Uint32 height 
2362         Uint32 depth 
2363         GLenum format
2364         GLenum type
2365         Sint32 level
2366         Sint32 base
2367         Sint32 max
2368         char *data
2369         CODE:
2370                 RETVAL = gluBuild3DMipmapLevels(target,internalFormat,width,height,depth,
2371                                 format,type,level,base,max,data);
2372         OUTPUT:
2373                 RETVAL
2374
2375 #else
2376 void
2377 gluBuild3DMipmapLevels ()
2378         CODE:
2379                 Perl_croak(aTHX_ "SDL::OpenGL::Build3DMipmapLevels requires GLU 1.2");          
2380
2381 #endif
2382
2383 char*
2384 gluErrorString ( code )
2385         GLenum code
2386         CODE:
2387                 RETVAL = (char*)gluErrorString(code);
2388         OUTPUT:
2389                 RETVAL
2390
2391 GLUnurbsObj*
2392 gluNewNurbsRenderer ()
2393         CODE:
2394                 RETVAL = gluNewNurbsRenderer();
2395         OUTPUT:
2396                 RETVAL
2397
2398 void
2399 gluDeleteNurbsRenderer ( obj )
2400         GLUnurbsObj *obj
2401         CODE:
2402                 gluDeleteNurbsRenderer(obj);
2403
2404 void
2405 gluNurbsProperty ( obj, property, value )
2406         GLUnurbsObj *obj
2407         GLenum property
2408         double value
2409         CODE:
2410                 gluNurbsProperty(obj,property,(float)value);
2411
2412 void
2413 gluLoadSamplingMatrices ( obj, mm, pm, vp )
2414         GLUnurbsObj *obj
2415         char *mm
2416         char *pm
2417         char *vp
2418         CODE:
2419                 gluLoadSamplingMatrices(obj,(GLfloat*)mm,(GLfloat*)pm,(GLint*)vp);
2420
2421 double
2422 gluGetNurbsProperty ( obj, property )
2423         GLUnurbsObj *obj
2424         GLenum property
2425         CODE:
2426                 float f;
2427                 gluGetNurbsProperty(obj,property,&f);
2428                 RETVAL = (double)f;
2429         OUTPUT:
2430                 RETVAL
2431
2432 void
2433 gluNurbsCallback ( obj, which, cb )
2434         GLUnurbsObj *obj
2435         GLenum which
2436         SV *cb
2437         CODE:
2438                 switch(which) {
2439                         case GLU_ERROR:
2440                                 sdl_perl_nurbs_error_hook = cb;
2441                                 gluNurbsCallback(obj,GLU_ERROR,(GLvoid*)sdl_perl_nurbs_error_callback);
2442                                 break;
2443 #ifdef GLU_NURBS_BEGIN
2444 #ifdef GLU_VERSION_1_3
2445                         case GLU_NURBS_BEGIN:
2446                         case GLU_NURBS_BEGIN_DATA:
2447
2448                                 gluNurbsCallbackData(obj,(void*)cb);
2449                                 gluNurbsCallback(obj,GLU_NURBS_BEGIN_DATA,
2450                                         (GLvoid*)sdl_perl_nurbs_being_callback);        
2451                                 break;
2452                         case GLU_NURBS_TEXTURE_COORD:
2453                         case GLU_NURBS_TEXTURE_COORD_DATA:
2454                                 gluNurbsCallbackData(obj,(void*)cb);
2455                                 gluNurbsCallback(obj,GLU_NURBS_TEXTURE_COORD_DATA,
2456                                         (GLvoid*)sdl_perl_nurbs_multi_callback);        
2457                                 break;
2458                         case GLU_NURBS_COLOR:
2459                         case GLU_NURBS_COLOR_DATA:
2460                                 gluNurbsCallbackData(obj,(void*)cb);
2461                                 gluNurbsCallback(obj,GLU_NURBS_COLOR_DATA,
2462                                         (GLvoid*)sdl_perl_nurbs_multi_callback);        
2463                                 break;
2464                         case GLU_NURBS_NORMAL:
2465                         case GLU_NURBS_NORMAL_DATA:
2466                                 gluNurbsCallbackData(obj,(void*)cb);
2467                                 gluNurbsCallback(obj,GLU_NURBS_NORMAL_DATA,
2468                                         (GLvoid*)sdl_perl_nurbs_multi_callback);        
2469                                 break;
2470                         case GLU_NURBS_VERTEX:
2471                         case GLU_NURBS_VERTEX_DATA:
2472                                 gluNurbsCallbackData(obj,(void*)cb);
2473                                 gluNurbsCallback(obj,GLU_NURBS_VERTEX_DATA,
2474                                         (GLvoid*)sdl_perl_nurbs_multi_callback);        
2475                                 break;
2476                         case GLU_NURBS_END:
2477                         case GLU_NURBS_END_DATA:
2478                                 gluNurbsCallbackData(obj,(void*)cb);
2479                                 gluNurbsCallback(obj,GLU_NURBS_END_DATA,
2480                                         (GLvoid*)sdl_perl_nurbs_end_callback);  
2481                                 break;
2482 #endif // GLU_VERSION_1_3
2483 #endif // GLU_NURBS_BEGIN
2484                         default:
2485                                 Perl_croak(aTHX_ "SDL::OpenGL::NurbsCallback - invalid type");
2486                 }
2487
2488 #ifdef GLU_VERSION_1_3
2489
2490 void
2491 gluNurbsCallbackData ( obj, cb )
2492         GLUnurbsObj *obj
2493         SV *cb
2494         CODE:
2495                 gluNurbsCallbackData(obj,(void*)cb);
2496
2497 #endif
2498
2499 void
2500 gluBeginSurface ( obj )
2501         GLUnurbsObj *obj
2502         CODE:
2503                 gluBeginSurface(obj);
2504
2505 void
2506 gluEndSurface ( obj )
2507         GLUnurbsObj *obj
2508         CODE:
2509                 gluEndSurface(obj);
2510         
2511 void
2512 gluNurbsSurface ( obj, uknot_count, uknot, vknot_count, vknot, u_stride, v_stride, ctlarray, uorder, vorder, type )
2513         GLUnurbsObj *obj
2514         Sint32 uknot_count
2515         char *uknot
2516         Sint32 vknot_count
2517         char *vknot
2518         Sint32 u_stride
2519         Sint32 v_stride
2520         char *ctlarray
2521         Sint32 uorder
2522         Sint32 vorder
2523         GLenum type
2524         CODE:
2525                 gluNurbsSurface(obj,uknot_count,(GLfloat*)uknot,vknot_count,(GLfloat*)vknot,
2526                         u_stride,v_stride,(GLfloat*)ctlarray,uorder,vorder,type);
2527
2528 void
2529 gluBeginCurve ( obj )
2530         GLUnurbsObj *obj
2531         CODE:
2532                 gluBeginCurve(obj);
2533
2534 void
2535 gluEndCurve ( obj ) 
2536         GLUnurbsObj *obj
2537         CODE:
2538                 gluEndCurve(obj);
2539
2540 void
2541 gluNurbsCurve ( obj, uknot_count, uknot, u_stride, ctlarray, uorder, type )
2542         GLUnurbsObj *obj
2543         Sint32 uknot_count
2544         char *uknot
2545         Sint32 u_stride
2546         char *ctlarray
2547         Sint32 uorder
2548         GLenum type
2549         CODE:
2550                 gluNurbsCurve(obj,uknot_count,(GLfloat*)uknot,u_stride,(GLfloat*)ctlarray,
2551                         uorder,type);
2552
2553 void
2554 gluBeginTrim ( obj )
2555         GLUnurbsObj *obj
2556         CODE:
2557                 gluBeginTrim(obj);
2558
2559 void
2560 gluEndTrim ( obj )
2561         GLUnurbsObj *obj
2562         CODE:
2563                 gluEndTrim(obj);
2564
2565 void
2566 gluPwlCurve ( obj, count, array, stride, type ) 
2567         GLUnurbsObj *obj
2568         Sint32 count
2569         char *array
2570         Sint32 stride
2571         GLenum type
2572         CODE:
2573                 gluPwlCurve(obj,count,(GLfloat*)array,stride,type);
2574
2575 AV*
2576 gluUnProject ( winx, winy, winz, mm, pm, vp )
2577         double winx
2578         double winy
2579         double winz
2580         char *mm
2581         char *pm
2582         char *vp
2583         CODE:
2584                 GLdouble objx, objy, objz;
2585                 RETVAL = newAV();
2586                 av_push(RETVAL,newSViv(gluUnProject(winx,winy,winz,(GLdouble*)mm,
2587                         (GLdouble*)pm,(GLint*)vp,&objx,&objy,&objz)));
2588                 av_push(RETVAL,newSVnv((double)objx));
2589                 av_push(RETVAL,newSVnv((double)objy));
2590                 av_push(RETVAL,newSVnv((double)objz));
2591         OUTPUT:
2592                 RETVAL
2593
2594
2595 #ifdef GL_VERSION_1_3
2596                 
2597 AV*
2598 gluUnProject4 ( winx, winy, winz, clipw, mm, pm, vp, n, f )
2599         double winx
2600         double winy
2601         double winz
2602         double clipw
2603         char *mm
2604         char *pm
2605         char *vp
2606         double n
2607         double f
2608         CODE:
2609                 GLdouble objx, objy, objz, objw;
2610                 RETVAL = newAV();
2611                 av_push(RETVAL,newSViv(gluUnProject4(winx,winy,winz,clipw,(GLdouble*)mm,
2612                         (GLdouble*)pm,(GLint*)vp,(GLclampd)n,(GLclampd)f,
2613                         &objx,&objy,&objz,&objw)));
2614                 av_push(RETVAL,newSVnv((double)objx));
2615                 av_push(RETVAL,newSVnv((double)objy));
2616                 av_push(RETVAL,newSVnv((double)objz));
2617                 av_push(RETVAL,newSVnv((double)objw));
2618         OUTPUT:
2619                 RETVAL
2620
2621 #endif // GL_VERSION_1_3
2622
2623 AV*
2624 gluProject ( objx, objy, objz, mm, pm, vp )
2625         double objx
2626         double objy
2627         double objz
2628         char *mm
2629         char *pm
2630         char *vp
2631         CODE:
2632                 GLdouble winx, winy, winz;
2633                 RETVAL = newAV();
2634                 av_push(RETVAL,newSViv(gluUnProject(objx,objy,objz,(GLdouble*)mm,
2635                         (GLdouble*)pm,(GLint*)vp,&winx,&winy,&winz)));
2636                 av_push(RETVAL,newSVnv((double)winx));
2637                 av_push(RETVAL,newSVnv((double)winy));
2638                 av_push(RETVAL,newSVnv((double)winz));
2639         OUTPUT:
2640                 RETVAL
2641
2642 #ifdef GL_VERSION_1_2
2643
2644 GLUtesselator*
2645 gluNewTess ()
2646         CODE:
2647                 RETVAL = gluNewTess();
2648         OUTPUT:
2649                 RETVAL
2650
2651 void
2652 gluTessCallback ( tess, type )
2653         GLUtesselator *tess
2654         GLenum type
2655         CODE:
2656                 switch(type) {
2657                         case GLU_TESS_BEGIN:
2658                         case GLU_TESS_BEGIN_DATA:
2659                                 gluTessCallback(tess,GLU_TESS_BEGIN_DATA,
2660                                         (GLvoid*)sdl_perl_tess_begin_callback); 
2661                                 break;
2662         
2663                         case GLU_TESS_EDGE_FLAG:
2664                         case GLU_TESS_EDGE_FLAG_DATA:
2665                                 gluTessCallback(tess,GLU_TESS_EDGE_FLAG_DATA,
2666                                         (GLvoid*)sdl_perl_tess_edge_flag_callback);     
2667                                 break;
2668
2669                         case GLU_TESS_VERTEX:
2670                         case GLU_TESS_VERTEX_DATA:
2671                                 gluTessCallback(tess,GLU_TESS_VERTEX_DATA,
2672                                         (GLvoid*)sdl_perl_tess_vertex_callback);        
2673                                 break;
2674
2675                         case GLU_TESS_END:
2676                         case GLU_TESS_END_DATA:
2677                                 gluTessCallback(tess,GLU_TESS_END_DATA,
2678                                         (GLvoid*)sdl_perl_tess_end_callback);   
2679                                 break;
2680
2681                         case GLU_TESS_COMBINE:
2682                         case GLU_TESS_COMBINE_DATA:
2683                                 gluTessCallback(tess,GLU_TESS_COMBINE_DATA,
2684                                         (GLvoid*)sdl_perl_tess_combine_callback);       
2685                                 break;
2686
2687                         case GLU_TESS_ERROR:
2688                         case GLU_TESS_ERROR_DATA:
2689                                 gluTessCallback(tess,GLU_TESS_ERROR_DATA,
2690                                         (GLvoid*)sdl_perl_tess_error_callback); 
2691                                 break;
2692                 }
2693
2694 void
2695 gluTessProperty ( tessobj, property, value )
2696         GLUtesselator *tessobj
2697         Uint32 property
2698         double value
2699         CODE:
2700                 gluTessProperty(tessobj,property,value);
2701
2702 double
2703 gluGetTessProperty ( tessobj, property )
2704         GLUtesselator *tessobj
2705         Uint32 property
2706         CODE:
2707                 gluGetTessProperty(tessobj,property,&RETVAL);
2708         OUTPUT:
2709                 RETVAL
2710
2711 void
2712 gluTessNormal ( tessobj, x, y, z )
2713         GLUtesselator *tessobj
2714         double x
2715         double y
2716         double z
2717         CODE:
2718                 gluTessNormal(tessobj,x,y,z);
2719
2720 void
2721 gluTessBeginPolygon ( tessobj, cb )
2722         GLUtesselator *tessobj
2723         SV *cb
2724         CODE:
2725                 gluTessBeginPolygon(tessobj,cb);
2726
2727 void
2728 gluTessEndPolygon ( tessobj ) 
2729         GLUtesselator *tessobj
2730         CODE:
2731                 gluTessEndPolygon(tessobj);
2732
2733 void
2734 gluTessBeginContour ( tessobj )
2735         GLUtesselator *tessobj
2736         CODE:
2737                 gluTessBeginContour(tessobj);
2738
2739 void
2740 gluTessEndContour ( tessobj )
2741         GLUtesselator *tessobj
2742         CODE:
2743                 gluTessEndContour(tessobj);
2744
2745 void
2746 gluDeleteTess ( tessobj )
2747         GLUtesselator *tessobj
2748         CODE:
2749                 gluDeleteTess(tessobj);
2750
2751 void
2752 gluTessVertex ( tessobj, coords, vd ) 
2753         GLUtesselator *tessobj
2754         char *coords
2755         char *vd
2756         CODE:
2757                 gluTessVertex(tessobj,(GLdouble*)coords,vd);
2758         
2759 #endif
2760
2761 GLUquadric *
2762 gluNewQuadric ()
2763         CODE:
2764                 RETVAL = gluNewQuadric ();
2765         OUTPUT:
2766                 RETVAL
2767
2768 void
2769 gluDeleteQuadric (quad)
2770         GLUquadric      *quad
2771
2772 void
2773 gluQuadricNormals ( quad, normal )
2774         GLUquadric *quad
2775         GLenum  normal
2776
2777 void
2778 gluQuadricTexture ( quad, texture )
2779         GLUquadric *quad
2780         GLboolean  texture
2781
2782 void
2783 gluCylinder ( quad, base, top, height, slices, stacks )
2784         GLUquadric *quad
2785         GLdouble  base
2786         GLdouble  top
2787         GLdouble  height
2788         GLint  slices
2789         GLint  stacks
2790
2791 void
2792 gluDisk ( quad, inner, outer, slices, loops )
2793         GLUquadric *quad
2794         GLdouble inner
2795         GLdouble outer
2796         GLint slices
2797         GLint loops
2798
2799 void
2800 gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep )
2801         GLUquadric *quad
2802         GLdouble inner
2803         GLdouble outer
2804         GLint slices
2805         GLint loops
2806         GLdouble start
2807         GLdouble sweep
2808
2809 void
2810 gluSphere ( quad, radius, slices, stacks )
2811         GLUquadric *quad
2812         GLdouble radius
2813         GLint  slices
2814         GLint  stacks
2815
2816 #endif
2817