X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FOpenGL.xs;h=841d92b6740a30941dd0d89d6a45e0abded4368a;hb=88a46efcf6e474bacd1399d8dbb590e4a183bff3;hp=d027d10a13fa11aa4671667fb97c7433f2c30270;hpb=faad43be293c8de28169e2ee12ab99a881c50bf4;p=sdlgit%2FSDL_perl.git diff --git a/src/OpenGL.xs b/src/OpenGL.xs index d027d10..841d92b 100644 --- a/src/OpenGL.xs +++ b/src/OpenGL.xs @@ -1,6 +1,31 @@ -// SDL::OpenGL // -// Copyright (C) 2002,2003,2004 David J. Goehrig +// OpenGL.xs +// +// Copyright (C) 2005 David J. Goehrig +// +// ------------------------------------------------------------------------------ +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +// ------------------------------------------------------------------------------ +// +// Please feel free to send questions, suggestions or improvements to: +// +// David J. Goehrig +// dgoehrig@cpan.org +// #include "EXTERN.h" #include "perl.h" @@ -12,9 +37,27 @@ #include +#ifdef PERL_DARWIN #include #include -#include +#else +#include + +#if defined(__WIN32__) && defined(__MINGW32__) +/* +this is a sort of dirty hack - MS Windows supports just OpenGL 1.1 and all 1.2+ +related stuff was moved from GL/gl.h to GL/glext.h; however this separation +was done not properly and even if we are OK with OpenGL 1.1 there are some +constants missing in GL/gl.h thus we need also GL/glext.h +*/ +#include +#undef GL_VERSION_1_3 +#undef GL_VERSION_1_2 +#endif + +#include +#endif + #ifdef USE_THREADS #define HAVE_TLS_CONTEXT @@ -24,7 +67,9 @@ #define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFF #endif /* GL_ALL_CLIENT_BITS */ -#include "defines.h" +#define GL_HAS_NURBS + +#include "../../src/defines.h" SV* sdl_perl_nurbs_error_hook; void @@ -709,12 +754,6 @@ glGet ( param ) croak("Unknown glGet parameter!"); } -const char * glGetString ( name ) - GLenum name - CODE: - RETVAL = (const char *)glGetString (name); - OUTPUT: - RETVAL Uint32 glIsEnabled ( cap ) @@ -851,6 +890,8 @@ glDrawElements ( mode, count, type, indices ) CODE: glDrawElements( mode, count, type, indices); +#ifdef GL_VERSION_1_2 + void glDrawRangeElements ( mode, start, end, count, type, indices ) GLenum mode @@ -862,6 +903,8 @@ glDrawRangeElements ( mode, start, end, count, type, indices ) CODE: glDrawRangeElements(mode,start,end,count,type,indices); +#endif // GL_VERSION_1_2 + void glDrawArrays ( mode, first, count ) GLenum mode @@ -917,7 +960,7 @@ glLoadMatrix ( ... ) int i; double mat[16]; for ( i = 0; i < 16; i++ ) { - mat[i] = (i < items && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 ); + mat[i] = i < items ? SvNV(ST(i)) : 0.0; } glLoadMatrixd(mat); @@ -927,7 +970,7 @@ glMultMatrix ( ... ) int i; double mat[16]; for ( i = 0; i < 16; i++ ) { - mat[i] = (i < items && SvNOK(ST(i)) ? SvNV(ST(i)) : 0.0 ); + mat[i] = i < items ? SvNV(ST(i)) : 0.0; } glMultMatrixd(mat); @@ -1011,7 +1054,7 @@ glClipPlane ( plane, ... ) double v[4]; int i; for (i = 0; i < 4; i++ ) { - v[i] = (i+1 < items && SvNOK(ST(i+1))) ? SvNV(ST(i+1)) : 0.0; + v[i] = i+1 < items ? SvNV(ST(i+1)) : 0.0; } glClipPlane(plane,v); @@ -1050,13 +1093,13 @@ glLight ( light, name, ... ) if ( items == 6 ) { float v[4]; for ( i = 0; i < 4; i++ ) { - v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0; + v[i] = SvNV(ST(i+2)); } glLightfv(light,name,v); } else if ( items == 5 ) { float v[3]; for ( i = 0; i < 3; i++ ) { - v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0; + v[i] = SvNV(ST(i+2)); } glLightfv(light,name,v); } else if ( items == 3 ) { @@ -1095,13 +1138,13 @@ glMaterial ( face, name, ... ) if ( items == 6 ) { float v[4]; for ( i = 0; i < 4; i++ ) { - v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0; + v[i] = SvNV(ST(i+2)); } glMaterialfv(face,name,v); } else if ( items == 5 ) { float v[3]; - for ( i = 0; i < 4; i++ ) { - v[i] = (SvNOK(ST(i+2))) ? SvNV(ST(i+2)) : 0.0; + for ( i = 0; i < 3; i++ ) { + v[i] = SvNV(ST(i+2)); } glMaterialfv(face,name,v); } else if ( items == 3 ) { @@ -1232,24 +1275,16 @@ glCallListsString ( string ) glCallLists(len,GL_BYTE,str); void -glRasterPos ( x, y, ... ) +glRasterPos ( x, y, z, ... ) double x double y + double z CODE: - if (items == 2) - { - glRasterPos2d (x,y); - } - else if (items == 3) - { - double z = SvNV (ST(2)); - glRasterPos3d (x,y,z); - } - else if (items == 4) - { - double z = SvNV (ST(2)); - double w = SvNV (ST(3)); - glRasterPos4d (x,y,z,w); + if ( items == 4 ) { + double w = SvNV(ST(3)); + glRasterPos4d(x,y,z,w); + } else { + glRasterPos3d(x,y,z); } void @@ -1733,9 +1768,9 @@ AV* glGenTextures ( n ) Uint32 n; CODE: - Uint32 i; - Uint32 *names; - names = (Uint32*)safemalloc(sizeof(Uint32)*n); + GLsizei i; + GLuint* names; + names = (GLuint*)safemalloc(sizeof(GLuint)*n); RETVAL = newAV(); glGenTextures(n,names); for ( i = 0; i < n; i++ ) { @@ -1763,9 +1798,9 @@ glBindTexture ( target, texture ) void glDeleteTextures ( ... ) CODE: - Uint32 *textures; + GLuint* textures; int i; - textures = (Uint32*)safemalloc(sizeof(Uint32) * items); + textures = (GLuint*)safemalloc(sizeof(GLuint) * items); if ( textures ) { for ( i = 0; i < items; i++ ) { textures[i] = SvIV(ST(i)); @@ -1777,11 +1812,11 @@ glDeleteTextures ( ... ) AV* glAreTexturesResident ( ... ) CODE: - Uint32 *textures; + GLuint* textures; GLboolean *homes; int i; RETVAL = newAV(); - textures = (Uint32*)safemalloc(sizeof(Uint32) * items); + textures = (GLuint*)safemalloc(sizeof(GLuint) * items); homes = (GLboolean*)safemalloc(sizeof(GLboolean) * items); if ( textures ) { for ( i = 0; i < items; i++ ) { @@ -2408,8 +2443,10 @@ gluNurbsCallback ( obj, which, cb ) gluNurbsCallback(obj,GLU_ERROR,(GLvoid*)sdl_perl_nurbs_error_callback); break; #ifdef GLU_NURBS_BEGIN +#ifdef GLU_VERSION_1_3 case GLU_NURBS_BEGIN: case GLU_NURBS_BEGIN_DATA: + gluNurbsCallbackData(obj,(void*)cb); gluNurbsCallback(obj,GLU_NURBS_BEGIN_DATA, (GLvoid*)sdl_perl_nurbs_being_callback); @@ -2444,11 +2481,14 @@ gluNurbsCallback ( obj, which, cb ) gluNurbsCallback(obj,GLU_NURBS_END_DATA, (GLvoid*)sdl_perl_nurbs_end_callback); break; -#endif +#endif // GLU_VERSION_1_3 +#endif // GLU_NURBS_BEGIN default: Perl_croak(aTHX_ "SDL::OpenGL::NurbsCallback - invalid type"); } +#ifdef GLU_VERSION_1_3 + void gluNurbsCallbackData ( obj, cb ) GLUnurbsObj *obj @@ -2456,6 +2496,8 @@ gluNurbsCallbackData ( obj, cb ) CODE: gluNurbsCallbackData(obj,(void*)cb); +#endif + void gluBeginSurface ( obj ) GLUnurbsObj *obj @@ -2728,23 +2770,16 @@ gluNewQuadric () void gluDeleteQuadric (quad) GLUquadric *quad - CODE: - gluDeleteQuadric(quad); void gluQuadricNormals ( quad, normal ) GLUquadric *quad GLenum normal - CODE: - gluQuadricNormals(quad, normal); - void gluQuadricTexture ( quad, texture ) GLUquadric *quad GLboolean texture - CODE: - gluQuadricTexture ( quad, texture ); void gluCylinder ( quad, base, top, height, slices, stacks ) @@ -2754,8 +2789,6 @@ gluCylinder ( quad, base, top, height, slices, stacks ) GLdouble height GLint slices GLint stacks - CODE: - gluCylinder ( quad, base, top, height, slices, stacks ); void gluDisk ( quad, inner, outer, slices, loops ) @@ -2764,9 +2797,7 @@ gluDisk ( quad, inner, outer, slices, loops ) GLdouble outer GLint slices GLint loops - CODE: - gluDisk ( quad, inner, outer, slices, loops ); - + void gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep ) GLUquadric *quad @@ -2776,9 +2807,6 @@ gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep ) GLint loops GLdouble start GLdouble sweep - - CODE: - gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep ); void gluSphere ( quad, radius, slices, stacks ) @@ -2786,19 +2814,6 @@ gluSphere ( quad, radius, slices, stacks ) GLdouble radius GLint slices GLint stacks - CODE: - gluSphere ( quad, radius, slices, stacks ); - - - -void -glXUseXFont ( font, first, count, list_base ) - Font font - int first - int count - int list_base - CODE: - glXUseXFont ( font, first, count, list_base ); #endif