4 // Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
6 // ------------------------------------------------------------------------------
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.
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.
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
22 // ------------------------------------------------------------------------------
24 // Please feel free to send questions, suggestions or improvements to:
46 #if defined(__WIN32__) && defined(__MINGW32__)
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
63 #define HAVE_TLS_CONTEXT
66 #ifndef GL_ALL_CLIENT_ATTRIB_BITS
67 #define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFF
68 #endif /* GL_ALL_CLIENT_BITS */
70 #include "../../src/defines.h"
72 SV* sdl_perl_nurbs_error_hook;
74 sdl_perl_nurbs_error_callback ( GLenum errorCode )
82 XPUSHs(sv_2mortal(newSViv(errorCode)));
85 call_sv(sdl_perl_nurbs_error_hook,G_VOID);
93 sdl_perl_nurbs_being_callback ( GLenum type, void *cb )
104 XPUSHs(sv_2mortal(newSViv(type)));
115 sdl_perl_nurbs_multi_callback ( GLfloat *vec, void *cb )
126 XPUSHs(sv_2mortal(newSViv(PTR2IV(vec))));
137 sdl_perl_nurbs_end_callback ( void *cb )
155 sdl_perl_tess_end_callback ( void *cb )
166 XPUSHs(sv_2mortal(newSViv(GLU_TESS_BEGIN)));
177 sdl_perl_tess_begin_callback ( GLenum type, void *cb )
188 XPUSHs(sv_2mortal(newSViv(GLU_TESS_BEGIN)));
189 XPUSHs(sv_2mortal(newSViv(type)));
200 sdl_perl_tess_error_callback ( GLenum type, void *cb )
211 XPUSHs(sv_2mortal(newSViv(GLU_TESS_ERROR)));
212 XPUSHs(sv_2mortal(newSViv(type)));
223 sdl_perl_tess_edge_flag_callback ( GLenum flag, void *cb )
234 XPUSHs(sv_2mortal(newSViv(GLU_TESS_EDGE_FLAG)));
235 XPUSHs(sv_2mortal(newSViv(flag)));
246 sdl_perl_tess_vertex_callback ( double *vd, void *cb )
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])));
274 sdl_perl_tess_combine_callback ( GLdouble coords[3], double *vd[4], GLfloat weight[4],
275 GLdouble **out, void *cb )
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)));
294 if ( 1 != call_sv(cmd,G_SCALAR) ) {
295 Perl_croak(aTHX_ "sdl_perl_tess_combine_callback failed");
298 data = (double*)POPp;
300 *out = (double*)malloc(sizeof(double)*width);
301 memcpy(*out,data,sizeof(double)*width);
308 MODULE = SDL::OpenGL PACKAGE = SDL::OpenGL
314 glClearColor ( r, g, b, a)
320 glClearColor((GLfloat)r,(GLfloat)g,(GLfloat)b,(GLfloat)a);
323 glClearIndex ( index )
329 glClearDepth ( depth )
341 glClearAccum ( r, g, b, a )
347 glClearAccum((GLfloat)r,(GLfloat)g,(GLfloat)b,(GLfloat)a);
369 glRecti(r->x,r->y,r->x+r->w,r->y+r->h);
372 glVertex ( x, y, ... )
381 } else if ( items == 3 ) {
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:
422 case GL_TEXTURE_GEN_S:
423 case GL_MAP1_VERTEX_3:
426 case GL_NORMAL_ARRAY:
430 case GL_POLYGON_OFFSET_FILL:
431 case GL_MAP1_TEXTURE_COORD_4:
434 case GL_UNPACK_SWAP_BYTES:
436 case GL_POLYGON_OFFSET_POINT:
437 case GL_POINT_SMOOTH:
439 case GL_MAP2_TEXTURE_COORD_4:
441 case GL_POLYGON_OFFSET_LINE:
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:
449 case GL_DOUBLEBUFFER:
450 case GL_UNPACK_LSB_FIRST:
451 case GL_TEXTURE_COORD_ARRAY:
453 case GL_TEXTURE_GEN_Q:
461 case GL_TEXTURE_GEN_R:
462 case GL_PACK_SWAP_BYTES:
463 case GL_DEPTH_WRITEMASK:
464 case GL_COLOR_LOGIC_OP:
469 case GL_COLOR_MATERIAL:
472 case GL_MAP1_VERTEX_4:
476 case GL_POLYGON_SMOOTH:
478 case GL_MAP2_COLOR_4:
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:
487 case GL_MAP1_COLOR_4:
488 case GL_MAP2_TEXTURE_COORD_1:
489 case GL_CURRENT_RASTER_POSITION_VALID:
491 case GL_SCISSOR_TEST:
493 case GL_POLYGON_STIPPLE:
496 case GL_LINE_STIPPLE:
497 case GL_MAP2_VERTEX_4:
501 glGetBooleanv(param, ret);
503 for (i = 0; i < 1; i++) {
504 XPUSHs(sv_2mortal(newSViv(ret[i])));
508 case GL_COLOR_WRITEMASK:
512 glGetBooleanv(param, ret);
514 for (i = 0; i < 4; i++) {
515 XPUSHs(sv_2mortal(newSViv(ret[i])));
520 case GL_ALPHA_TEST_REF:
521 case GL_POINT_SIZE_GRANULARITY:
522 case GL_CURRENT_RASTER_DISTANCE:
528 case GL_DEPTH_CLEAR_VALUE:
535 case GL_POLYGON_OFFSET_FACTOR:
538 case GL_POLYGON_OFFSET_UNITS:
540 case GL_LINE_WIDTH_GRANULARITY:
546 glGetDoublev(param, ret);
548 for (i = 0; i < 1; i++) {
549 XPUSHs(sv_2mortal(newSVnv(ret[i])));
553 case GL_MODELVIEW_MATRIX:
554 case GL_TEXTURE_MATRIX:
555 case GL_PROJECTION_MATRIX:
559 glGetDoublev(param, ret);
561 for (i = 0; i < 16; i++) {
562 XPUSHs(sv_2mortal(newSVnv(ret[i])));
566 case GL_POINT_SIZE_RANGE:
567 case GL_LINE_WIDTH_RANGE:
568 case GL_MAP1_GRID_DOMAIN:
573 glGetDoublev(param, ret);
575 for (i = 0; i < 2; i++) {
576 XPUSHs(sv_2mortal(newSVnv(ret[i])));
580 case GL_CURRENT_NORMAL:
584 glGetDoublev(param, ret);
586 for (i = 0; i < 3; i++) {
587 XPUSHs(sv_2mortal(newSVnv(ret[i])));
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:
605 glGetDoublev(param, ret);
607 for (i = 0; i < 4; i++) {
608 XPUSHs(sv_2mortal(newSVnv(ret[i])));
612 case GL_CULL_FACE_MODE:
613 case GL_PIXEL_MAP_I_TO_A_SIZE:
614 case GL_PIXEL_MAP_A_TO_A_SIZE:
616 case GL_EDGE_FLAG_ARRAY_STRIDE:
621 case GL_POINT_SMOOTH_HINT:
622 case GL_PACK_SKIP_PIXELS:
624 case GL_STENCIL_CLEAR_VALUE:
626 case GL_COLOR_MATERIAL_PARAMETER:
627 case GL_ACCUM_BLUE_BITS:
629 case GL_VERTEX_ARRAY_STRIDE:
630 case GL_STENCIL_PASS_DEPTH_PASS:
631 case GL_CLIENT_ATTRIB_STACK_DEPTH:
633 case GL_LINE_STIPPLE_REPEAT:
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:
642 case GL_LINE_SMOOTH_HINT:
643 case GL_ALPHA_TEST_FUNC:
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:
653 case GL_ACCUM_ALPHA_BITS:
654 case GL_INDEX_ARRAY_STRIDE:
655 case GL_PIXEL_MAP_I_TO_B_SIZE:
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:
664 case GL_COLOR_ARRAY_STRIDE:
666 case GL_UNPACK_SKIP_PIXELS:
667 case GL_PIXEL_MAP_G_TO_G_SIZE:
668 case GL_VERTEX_ARRAY_TYPE:
670 case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
671 case GL_INDEX_CLEAR_VALUE:
672 case GL_PIXEL_MAP_I_TO_G_SIZE:
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:
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:
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:
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:
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:
719 glGetIntegerv(param, ret);
721 for (i = 0; i < 1; i++) {
722 XPUSHs(sv_2mortal(newSViv(ret[i])));
726 case GL_POLYGON_MODE:
727 case GL_MAX_VIEWPORT_DIMS:
728 case GL_MAP2_GRID_SEGMENTS:
732 glGetIntegerv(param, ret);
734 for (i = 0; i < 2; i++) {
735 XPUSHs(sv_2mortal(newSViv(ret[i])));
744 glGetIntegerv(param, ret);
746 for (i = 0; i < 4; i++) {
747 XPUSHs(sv_2mortal(newSViv(ret[i])));
752 croak("Unknown glGet parameter!");
760 RETVAL = glIsEnabled(cap);
768 glPointSize((GLfloat)size);
774 glLineWidth((GLfloat)size);
777 glLineStipple ( factor, pattern )
781 glLineStipple(factor,pattern);
784 glPolygonMode ( face, mode )
788 glPolygonMode(face,mode);
803 glPolygonStipple ( mask )
806 glPolygonStipple(mask);
823 glEnableClientState ( array )
826 glEnableClientState(array);
829 glDisableClientState ( array )
832 glDisableClientState(array);
835 glVertexPointer ( size, type, stride, pointer)
841 glVertexPointer(size,type,stride,pointer);
844 glColorPointer ( size, type, stride, pointer )
850 glColorPointer(size,type,stride,pointer);
853 glNormalPointer ( type, stride, pointer )
858 glNormalPointer(type,stride,pointer);
861 glTexCoordPointer ( size, type, stride, pointer )
867 glTexCoordPointer(size,type,stride,pointer);
870 glEdgeFlagPointer ( stride, pointer )
874 glEdgeFlagPointer(stride,pointer);
877 glArrayElement ( ith )
883 glDrawElements ( mode, count, type, indices )
889 glDrawElements( mode, count, type, indices);
891 #ifdef GL_VERSION_1_2
894 glDrawRangeElements ( mode, start, end, count, type, indices )
902 glDrawRangeElements(mode,start,end,count,type,indices);
904 #endif // GL_VERSION_1_2
907 glDrawArrays ( mode, first, count )
912 glDrawArrays(mode,first,count);
915 glInterleavedArrays ( format, stride, pointer )
920 glInterleavedArrays(format,stride,pointer);
923 glPushAttrib ( mask )
934 glPushClientAttrib ( mask )
937 glPushClientAttrib(mask);
945 glMatrixMode ( mode )
960 for ( i = 0; i < 16; i++ ) {
961 mat[i] = (i < items && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 );
970 for ( i = 0; i < 16; i++ ) {
971 mat[i] = (i < items && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 );
976 glTranslate ( x, y, z )
984 glRotate ( angle, x, y, z )
990 glRotated(angle,x,y,z);
1001 glFrustum ( left, right, bottom, top, n, f )
1009 glFrustum(left,right,bottom,top,n,f);
1012 glOrtho ( left, right, bottom, top, n, f )
1020 glOrtho(left,right,bottom,top,n,f);
1023 glViewport ( x, y, width, height )
1029 glViewport(x,y,width,height);
1032 glDepthRange ( n, f )
1049 glClipPlane ( plane, ... )
1054 for (i = 0; i < 4; i++ ) {
1055 v[i] = (i+1 < items && SvNOK(ST(i+1))) ? SvNV(ST(i+1)) : 0.0;
1057 glClipPlane(plane,v);
1060 glColor ( r, g, b, ... )
1080 glShadeModel ( mode )
1086 glLight ( light, name, ... )
1093 for ( i = 0; i < 4; i++ ) {
1094 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1096 glLightfv(light,name,v);
1097 } else if ( items == 5 ) {
1099 for ( i = 0; i < 3; i++ ) {
1100 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1102 glLightfv(light,name,v);
1103 } else if ( items == 3 ) {
1106 glLightf(light,name,v);
1108 Perl_croak(aTHX_ "SDL::OpenGL::Light invalid arguments");
1112 glLightModel ( pname, ... )
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);
1127 Perl_croak(aTHX_ "SDL::OpenGL::glLightModel unknown model %d",pname);
1131 glMaterial ( face, name, ... )
1138 for ( i = 0; i < 4; i++ ) {
1139 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1141 glMaterialfv(face,name,v);
1142 } else if ( items == 5 ) {
1144 for ( i = 0; i < 4; i++ ) {
1145 v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0;
1147 glMaterialfv(face,name,v);
1148 } else if ( items == 3 ) {
1151 glMaterialf(face,name,v);
1153 Perl_croak(aTHX_ "SDL::OpenGL::Material invalid arguments");
1157 glColorMaterial ( face, mode )
1161 glColorMaterial(face,mode);
1164 glBlendFunc ( sfactor, dfactor )
1168 glBlendFunc(sfactor,dfactor);
1172 glHint ( target, hint )
1176 glHint(target,hint);
1189 } else if ( items == 2 ) {
1194 Perl_croak(aTHX_ "SDL::OpenGL::Material invalid arguments");
1198 glPolygonOffset ( factor, units )
1202 glPolygonOffset(factor,units);
1205 glGenLists ( range )
1208 RETVAL = glGenLists(range);
1213 glNewList ( list, mode )
1217 glNewList(list,mode);
1225 glDeleteLists ( base, count )
1229 glDeleteLists(base, count);
1241 RETVAL = glIsList(list);
1256 i = (int*)safemalloc(sizeof(int)* (items));
1257 for ( j = 0; j < items; j++ ) {
1261 Perl_croak(aTHX_ "usage: SDL::OpenGL::CallLists(type,...)");
1263 glCallLists(items, GL_INT, i);
1267 glCallListsString ( string )
1272 str = SvPV(string,len);
1273 glCallLists(len,GL_BYTE,str);
1276 glRasterPos ( x, y, z, ... )
1282 double w = SvNV(ST(3));
1283 glRasterPos4d(x,y,z,w);
1285 glRasterPos3d(x,y,z);
1289 glBitmap ( width, height, x1, y1, x2, y2, data )
1298 glBitmap(width,height,x1,y1,x2,y2,data);
1301 glDrawPixels ( width, height, format, type, pixels )
1308 glDrawPixels(width,height,format,type,pixels);
1312 glReadPixels ( x, y, width, height, format, type )
1322 size = 1; /* ALPHA, BLUE, GREEN or RED */
1323 if (format == GL_BGR || format == GL_RGB)
1325 if (format == GL_BGRA || format == GL_RGBA)
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 */
1337 glReadPixel ( x, y )
1341 int rgba[4]; /* r,g,b,a */
1343 glReadPixels(x,y,1,1,GL_RGBA,GL_UNSIGNED_INT,rgba);
1345 for ( i = 0; i < 4; i++ ) {
1346 av_push(RETVAL,newSViv(rgba[i]));
1352 glCopyPixels ( x, y, width, height, buffer )
1359 glCopyPixels(x,y,width,height,buffer);
1362 glPixelStore ( name, param )
1366 glPixelStorei(name,param);
1369 glPixelTransfer ( name, ... )
1374 case GL_MAP_STENCIL:
1375 case GL_INDEX_SHIFT:
1376 case GL_INDEX_OFFSET:
1377 glPixelTransferi(name,SvIV(ST(1)));
1380 glPixelTransferf(name,SvNV(ST(1)));
1385 glPixelMap ( type, map, mapsize, values )
1392 case GL_UNSIGNED_INT:
1393 glPixelMapuiv(map,mapsize,(GLint*)values);
1395 case GL_UNSIGNED_SHORT:
1396 glPixelMapusv(map,mapsize,(GLushort*)values);
1399 glPixelMapfv(map,mapsize,(GLfloat*)values);
1404 glPixelZoom ( zoomx, zoomy )
1408 glPixelZoom(zoomx,zoomy);
1410 #ifdef GL_VERSION_1_3
1413 glColorTable ( target, internalFormat, width, format, type, data )
1415 GLenum internalFormat
1421 glColorTable(target,internalFormat,width,format,type,data);
1424 glColorTableParameter ( target, name, r, g, b, a)
1437 glColorTableParameterfv(target,name,vec);
1440 glCopyColorTable ( target, internalFormat, x, y, width )
1442 GLenum internalFormat
1447 glCopyColorTable(target,internalFormat,x,y,width);
1450 glColorSubTable ( target, start, count, format, type, data )
1458 glColorSubTable(target,start,count,format,type,data);
1461 glCopyColorSubTable ( target, start, x, y, count )
1468 glCopyColorSubTable(target,start,x,y,count);
1471 glConvolutionFilter2D ( target, internalFormat, width, height, format, type, image )
1473 Uint32 internalFormat
1480 glConvolutionFilter2D(target,internalFormat,width,height,format,type,image);
1483 glCopyConvolutionFilter2D ( target, internalFormat, x, y, width, height )
1485 Uint32 internalFormat
1491 glCopyConvolutionFilter2D(target,internalFormat,x,y,width,height);
1494 glSeparableFilter2D ( target, internalFormat, width, height, format, type, row, column )
1496 Uint32 internalFormat
1504 glSeparableFilter2D(target,internalFormat,width,height,format,type,row,column);
1507 glConvolutionFilter1D ( target, internalFormat, width, format, type, image )
1509 Uint32 internalFormat
1515 glConvolutionFilter1D(target,internalFormat,width,format,type,image);
1518 glCopyConvolutionFilter1D ( target, internalFormat, x, y, width )
1520 Uint32 internalFormat
1525 glCopyConvolutionFilter1D(target,internalFormat,x,y,width);
1528 glConvolutionParameter ( target, pname, ... )
1535 case GL_CONVOLUTION_BORDER_MODE:
1537 Perl_croak(aTHX_ "Usage: ConvolutionParameter(target,pname,...)");
1539 glConvolutionParameteri(target,pname,pi);
1541 case GL_CONVOLUTION_FILTER_SCALE:
1542 case GL_CONVOLUTION_FILTER_BIAS:
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);
1552 Perl_croak(aTHX_ "ConvolutionParameter invalid parameter");
1557 glHistogram ( target, width, internalFormat, sink )
1560 Uint32 internalFormat
1563 glHistogram(target,width,internalFormat,sink);
1566 glGetHistogram ( target, reset, format, type, values )
1573 glGetHistogram(target,reset,format,type,values);
1576 glResetHistogram ( target )
1579 glResetHistogram(target);
1582 glMinmax ( target, internalFormat, sink )
1584 Uint32 internalFormat
1587 glMinmax(target,internalFormat,sink);
1590 glGetMinmax ( target, reset, format, type, values )
1597 glGetMinmax(target,reset,format,type,values);
1600 glResetMinmax ( target )
1603 glResetMinmax(target);
1606 glBlendEquation ( mode )
1609 glBlendEquation(mode);
1611 #endif // GL_VERSION_1_3
1614 glTexImage2D ( target, level, internalFormat, width, height, border, format, type, data )
1617 Sint32 internalFormat
1625 glTexImage2D(target,level,internalFormat,width,height,border,format,type,data);
1628 glCopyTexImage2D ( target, level, internalFormat, x, y, width, height, border )
1631 Sint32 internalFormat
1638 glCopyTexImage2D(target,level,internalFormat,x,y,width,height,border);
1641 glTexSubImage2D ( target, level, xoffset, yoffset, width, height, format, type, data )
1652 glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,data);
1655 glCopyTexSubImage2D ( target, level, xoffset, yoffset, x, y, width, height )
1665 glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
1668 glTexImage1D ( target, level, internalFormat, width, border, format, type, data )
1671 Sint32 internalFormat
1678 glTexImage1D(target,level,internalFormat,width,border,format,type,data);
1681 glTexSubImage1D ( target, level, xoffset, width, format, type, data )
1690 glTexSubImage1D(target,level,xoffset,width,format,type,data);
1693 glCopyTexImage1D ( target, level, internalFormat, x, y, width, border )
1696 Sint32 internalFormat
1702 glCopyTexImage1D(target,level,internalFormat,x,y,width,border);
1705 glCopyTexSubImage1D ( target, level, xoffset, x, y, width )
1713 glCopyTexSubImage1D(target,level,xoffset,x,y,width);
1715 #ifdef GL_VERSION_1_3
1718 glTexImage3D ( target, level, internalFormat, width, height, depth, border, format, type, data )
1721 Sint32 internalFormat
1730 glTexImage3D(target,level,internalFormat,width,height,depth,border,format,type,data);
1733 glTexSubImage3D ( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data )
1746 glTexSubImage3D(target,level,xoffset,yoffset,zoffset,
1747 width,height,depth,format,type,data);
1750 glCopyTexSubImage3D ( target, level, xoffset, yoffset, zoffset, x, y, width, height )
1761 glCopyTexSubImage3D(target,level,xoffset,yoffset,zoffset,x,y,width,height);
1763 #endif // GL_VERSION_1_3
1771 names = (GLuint*)safemalloc(sizeof(GLuint)*n);
1773 glGenTextures(n,names);
1774 for ( i = 0; i < n; i++ ) {
1775 av_push(RETVAL,newSViv(names[i]));
1782 glIsTexture ( texture )
1785 RETVAL = glIsTexture(texture);
1790 glBindTexture ( target, texture )
1794 glBindTexture(target,texture);
1797 glDeleteTextures ( ... )
1801 textures = (GLuint*)safemalloc(sizeof(GLuint) * items);
1803 for ( i = 0; i < items; i++ ) {
1804 textures[i] = SvIV(ST(i));
1807 glDeleteTextures(items,textures);
1811 glAreTexturesResident ( ... )
1817 textures = (GLuint*)safemalloc(sizeof(GLuint) * items);
1818 homes = (GLboolean*)safemalloc(sizeof(GLboolean) * items);
1820 for ( i = 0; i < items; i++ ) {
1821 textures[i] = SvIV(ST(i));
1824 if ( GL_FALSE != glAreTexturesResident(items,textures,homes)) {
1825 for (i = 0; i < items; i++ ) {
1826 av_push(RETVAL,newSViv(homes[i]));
1835 glPrioritizeTextures ( n, names, priorities )
1840 glPrioritizeTextures(n,(GLuint*)names,(const GLclampf *)priorities);
1843 glTexEnv ( target, name, ... )
1850 case GL_TEXTURE_ENV_MODE:
1852 glTexEnvi(target,name,p);
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);
1867 if ( items < 1 || items > 4 )
1868 Perl_croak (aTHX_ "usage: SDL::OpenGL::TexCoord(s,[t,[r,[q]]])");
1881 glTexCoord4d(s,t,r,q);
1884 glTexParameter ( target, 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);
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]);
1904 case GL_TEXTURE_BASE_LEVEL:
1905 case GL_TEXTURE_MAX_LEVEL:
1908 glTexParameteri(target,name,p);
1913 glTexGen ( coord, name, ... )
1921 case GL_TEXTURE_GEN_MODE:
1923 glTexGeni(coord,name,p);
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));
1932 glTexGendv(coord,name,pv);
1937 #ifdef GL_VERSION_1_3
1940 glActiveTextureARB ( texUnit )
1943 glActiveTextureARB(texUnit);
1946 glMultiTexCoord ( texUnit, ... )
1950 if ( items < 2 || items > 5 )
1951 Perl_croak (aTHX_ "usage: SDL::OpenGL::MultiTexCoord(tex,s,[t,[r,[q]]])");
1964 glMultiTexCoord4dARB(texUnit,s,t,r,q);
1966 #endif // GL_VERSION_1_3
1969 glDrawBuffer ( mode )
1975 glReadBuffer ( mode )
1981 glIndexMask ( mask )
1987 glColorMask ( red, green, blue, alpha )
1993 glColorMask(red,green,blue,alpha);
1996 glDepthMask ( flag )
2002 glStencilMask ( mask )
2005 glStencilMask(mask);
2008 glScissor ( x , y, width, height )
2014 glScissor(x,y,width,height);
2017 glAlphaFunc ( func, ref )
2021 glAlphaFunc(func,ref);
2024 glStencilFunc ( func, ref, mask )
2029 glStencilFunc(func,ref,mask);
2032 glStencilOp ( fail, zfail, zpass )
2037 glStencilOp(fail,zfail,zpass);
2040 glDepthFunc ( func )
2046 glLogicOp ( opcode )
2052 glAccum ( op, value )
2059 glMap1 ( target, u1, u2, stride, order, points )
2067 glMap1d(target,u1,u2,stride,order,(double*)points);
2076 glMapGrid1 ( n, u1, u2 )
2081 glMapGrid1d(n,u1,u2);
2084 glEvalMesh1 ( mode, p1, p2 )
2089 glEvalMesh1(mode,p1,p2);
2092 glMap2 ( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points )
2104 glMap2d(target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,(double*)points);
2107 glEvalCoord2 ( u, v )
2114 glMapGrid2 ( nu, u1, u2, nv, v1, v2 )
2122 glMapGrid2d(nu,u1,u2,nv,v1,v2);
2125 glEvalMesh2 ( mode, i1, i2, j1, j2 )
2132 glEvalMesh2(mode,i1,i2,j1,j2);
2137 RETVAL = glGetError();
2142 glRenderMode ( mode )
2145 RETVAL = glRenderMode( mode );
2172 glFeedbackBuffer ( size, type, buffer )
2177 glFeedbackBuffer(size,type,buffer);
2180 glPassThrough ( token )
2183 glPassThrough(token);
2191 gluLookAt ( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz )
2202 gluLookAt(eyex,eyey,eyez,centerx,centery,centerz,upx,upy,upz);
2205 gluPerspective ( fovy, aspect, n, f )
2211 gluPerspective(fovy,aspect,n,f);
2214 gluPickMatrix ( x, y, delx, dely, viewport )
2221 gluPickMatrix(x,y,delx,dely,viewport);
2224 gluOrtho2D ( left, right, bottom, top )
2230 gluOrtho2D(left,right,bottom,top);
2233 gluScaleImage ( format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout )
2244 RETVAL = gluScaleImage(format,widthin,heightin,typein,datain,
2245 widthout,heightout,typeout,dataout);
2250 gluBuild1DMipmaps ( target, internalFormat, width, format, type, data )
2252 Sint32 internalFormat
2258 RETVAL = gluBuild1DMipmaps(target,internalFormat,width,format,type,data);
2263 gluBuild2DMipmaps ( target, internalFormat, width, height, format, type, data )
2265 Sint32 internalFormat
2272 RETVAL = gluBuild2DMipmaps(target,internalFormat,width,height,format,type,data);
2277 #if HAVE_GLU_VERSION >= 12
2279 gluBuild3DMipmaps ( target, internalFormat, width, height, depth, format, type, data )
2281 Sint32 internalFormat
2289 RETVAL = gluBuild3DMipmaps(target,internalFormat,width,height,depth,
2296 gluBuild3DMipmaps ( )
2298 Perl_croak (aTHX_ "SDL::OpenGL::Build3DMipmaps requires GLU 1.2");
2302 #if HAVE_GLU_VERSION >= 12
2304 gluBuild1DMipmapLevels ( target, internalFormat, width, format, type, level, base, max, data )
2306 Sint32 internalFormat
2315 RETVAL = gluBuild1DMipmapLevels(target,internalFormat,width,
2316 format,type,level,base,max,data);
2322 gluBuild1DMipmapLevels ()
2324 Perl_croak(aTHX_ "SDL::OpenGL::Build1DMipmapLevels requires GLU 1.2");
2328 #if HAVE_GLU_VERSION >= 12
2330 gluBuild2DMipmapLevels ( target, internalFormat, width, height, format, type, level, base, max, data )
2332 Sint32 internalFormat
2342 RETVAL = gluBuild2DMipmapLevels(target,internalFormat,width,height,
2343 format,type,level,base,max,data);
2349 gluBuild2DMipmapLevels ()
2351 Perl_croak(aTHX_ "SDL::OpenGL::Build2DMipmapLevels requires GLU 1.2");
2355 #if HAVE_GLU_VERSION >= 12
2357 gluBuild3DMipmapLevels ( target, internalFormat, width, height, depth, format, type, level, base, max, data )
2359 Sint32 internalFormat
2370 RETVAL = gluBuild3DMipmapLevels(target,internalFormat,width,height,depth,
2371 format,type,level,base,max,data);
2377 gluBuild3DMipmapLevels ()
2379 Perl_croak(aTHX_ "SDL::OpenGL::Build3DMipmapLevels requires GLU 1.2");
2384 gluErrorString ( code )
2387 RETVAL = (char*)gluErrorString(code);
2392 gluNewNurbsRenderer ()
2394 RETVAL = gluNewNurbsRenderer();
2399 gluDeleteNurbsRenderer ( obj )
2402 gluDeleteNurbsRenderer(obj);
2405 gluNurbsProperty ( obj, property, value )
2410 gluNurbsProperty(obj,property,(float)value);
2413 gluLoadSamplingMatrices ( obj, mm, pm, vp )
2419 gluLoadSamplingMatrices(obj,(GLfloat*)mm,(GLfloat*)pm,(GLint*)vp);
2422 gluGetNurbsProperty ( obj, property )
2427 gluGetNurbsProperty(obj,property,&f);
2433 gluNurbsCallback ( obj, which, cb )
2440 sdl_perl_nurbs_error_hook = cb;
2441 gluNurbsCallback(obj,GLU_ERROR,(GLvoid*)sdl_perl_nurbs_error_callback);
2443 #ifdef GLU_NURBS_BEGIN
2444 #ifdef GLU_VERSION_1_3
2445 case GLU_NURBS_BEGIN:
2446 case GLU_NURBS_BEGIN_DATA:
2448 gluNurbsCallbackData(obj,(void*)cb);
2449 gluNurbsCallback(obj,GLU_NURBS_BEGIN_DATA,
2450 (GLvoid*)sdl_perl_nurbs_being_callback);
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);
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);
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);
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);
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);
2482 #endif // GLU_VERSION_1_3
2483 #endif // GLU_NURBS_BEGIN
2485 Perl_croak(aTHX_ "SDL::OpenGL::NurbsCallback - invalid type");
2488 #ifdef GLU_VERSION_1_3
2491 gluNurbsCallbackData ( obj, cb )
2495 gluNurbsCallbackData(obj,(void*)cb);
2500 gluBeginSurface ( obj )
2503 gluBeginSurface(obj);
2506 gluEndSurface ( obj )
2512 gluNurbsSurface ( obj, uknot_count, uknot, vknot_count, vknot, u_stride, v_stride, ctlarray, uorder, vorder, type )
2525 gluNurbsSurface(obj,uknot_count,(GLfloat*)uknot,vknot_count,(GLfloat*)vknot,
2526 u_stride,v_stride,(GLfloat*)ctlarray,uorder,vorder,type);
2529 gluBeginCurve ( obj )
2541 gluNurbsCurve ( obj, uknot_count, uknot, u_stride, ctlarray, uorder, type )
2550 gluNurbsCurve(obj,uknot_count,(GLfloat*)uknot,u_stride,(GLfloat*)ctlarray,
2554 gluBeginTrim ( obj )
2566 gluPwlCurve ( obj, count, array, stride, type )
2573 gluPwlCurve(obj,count,(GLfloat*)array,stride,type);
2576 gluUnProject ( winx, winy, winz, mm, pm, vp )
2584 GLdouble objx, objy, objz;
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));
2595 #ifdef GL_VERSION_1_3
2598 gluUnProject4 ( winx, winy, winz, clipw, mm, pm, vp, n, f )
2609 GLdouble objx, objy, objz, objw;
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));
2621 #endif // GL_VERSION_1_3
2624 gluProject ( objx, objy, objz, mm, pm, vp )
2632 GLdouble winx, winy, winz;
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));
2642 #ifdef GL_VERSION_1_2
2647 RETVAL = gluNewTess();
2652 gluTessCallback ( tess, 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);
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);
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);
2676 case GLU_TESS_END_DATA:
2677 gluTessCallback(tess,GLU_TESS_END_DATA,
2678 (GLvoid*)sdl_perl_tess_end_callback);
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);
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);
2695 gluTessProperty ( tessobj, property, value )
2696 GLUtesselator *tessobj
2700 gluTessProperty(tessobj,property,value);
2703 gluGetTessProperty ( tessobj, property )
2704 GLUtesselator *tessobj
2707 gluGetTessProperty(tessobj,property,&RETVAL);
2712 gluTessNormal ( tessobj, x, y, z )
2713 GLUtesselator *tessobj
2718 gluTessNormal(tessobj,x,y,z);
2721 gluTessBeginPolygon ( tessobj, cb )
2722 GLUtesselator *tessobj
2725 gluTessBeginPolygon(tessobj,cb);
2728 gluTessEndPolygon ( tessobj )
2729 GLUtesselator *tessobj
2731 gluTessEndPolygon(tessobj);
2734 gluTessBeginContour ( tessobj )
2735 GLUtesselator *tessobj
2737 gluTessBeginContour(tessobj);
2740 gluTessEndContour ( tessobj )
2741 GLUtesselator *tessobj
2743 gluTessEndContour(tessobj);
2746 gluDeleteTess ( tessobj )
2747 GLUtesselator *tessobj
2749 gluDeleteTess(tessobj);
2752 gluTessVertex ( tessobj, coords, vd )
2753 GLUtesselator *tessobj
2757 gluTessVertex(tessobj,(GLdouble*)coords,vd);
2764 RETVAL = gluNewQuadric ();
2769 gluDeleteQuadric (quad)
2773 gluQuadricNormals ( quad, normal )
2778 gluQuadricTexture ( quad, texture )
2783 gluCylinder ( quad, base, top, height, slices, stacks )
2792 gluDisk ( quad, inner, outer, slices, loops )
2800 gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep )
2810 gluSphere ( quad, radius, slices, stacks )