X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FOpenGL.xs;h=841d92b6740a30941dd0d89d6a45e0abded4368a;hb=ae2d15942b5ee719ea5bb81d2486f8d1bb3a4f21;hp=bb84322d07456a12e53ffd8b7f6a0c9e8998258f;hpb=4db254ced364403ceacdc65192d8f7ccfe63278b;p=sdlgit%2FSDL_perl.git diff --git a/src/OpenGL.xs b/src/OpenGL.xs index bb84322..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,8 +37,27 @@ #include +#ifdef PERL_DARWIN #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 @@ -23,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 @@ -708,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 ) @@ -850,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 @@ -861,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 @@ -916,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); @@ -926,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); @@ -1010,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); @@ -1049,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 ) { @@ -1094,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 ) { @@ -1724,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++ ) { @@ -1754,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)); @@ -1768,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++ ) { @@ -2399,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); @@ -2435,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 @@ -2447,6 +2496,8 @@ gluNurbsCallbackData ( obj, cb ) CODE: gluNurbsCallbackData(obj,(void*)cb); +#endif + void gluBeginSurface ( obj ) GLUnurbsObj *obj @@ -2707,7 +2758,7 @@ gluTessVertex ( tessobj, coords, vd ) CODE: gluTessVertex(tessobj,(GLdouble*)coords,vd); - +#endif GLUquadric * gluNewQuadric () @@ -2719,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 ) @@ -2745,8 +2789,7 @@ 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 ) GLUquadric *quad @@ -2754,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 @@ -2766,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 ) @@ -2776,8 +2814,6 @@ gluSphere ( quad, radius, slices, stacks ) GLdouble radius GLint slices GLint stacks - CODE: - gluSphere ( quad, radius, slices, stacks ); #endif