X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2FOpenGL.xs;h=841d92b6740a30941dd0d89d6a45e0abded4368a;hb=473d3fa763da18283068457753d13c4701d0e197;hp=ae36df25ba01c47f0846286a1efb12cc2ec19069;hpb=8fde61e3e900d5000c94503679d735221acc1882;p=sdlgit%2FSDL_perl.git diff --git a/src/OpenGL.xs b/src/OpenGL.xs index ae36df2..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 @@ -844,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 @@ -855,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 @@ -910,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); @@ -920,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); @@ -1004,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); @@ -1043,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 ) { @@ -1088,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 ) { @@ -1718,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++ ) { @@ -1748,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)); @@ -1762,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++ ) { @@ -2393,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); @@ -2429,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 @@ -2441,6 +2496,8 @@ gluNurbsCallbackData ( obj, cb ) CODE: gluNurbsCallbackData(obj,(void*)cb); +#endif + void gluBeginSurface ( obj ) GLUnurbsObj *obj @@ -2703,5 +2760,60 @@ gluTessVertex ( tessobj, coords, vd ) #endif +GLUquadric * +gluNewQuadric () + CODE: + RETVAL = gluNewQuadric (); + OUTPUT: + RETVAL + +void +gluDeleteQuadric (quad) + GLUquadric *quad + +void +gluQuadricNormals ( quad, normal ) + GLUquadric *quad + GLenum normal + +void +gluQuadricTexture ( quad, texture ) + GLUquadric *quad + GLboolean texture + +void +gluCylinder ( quad, base, top, height, slices, stacks ) + GLUquadric *quad + GLdouble base + GLdouble top + GLdouble height + GLint slices + GLint stacks + +void +gluDisk ( quad, inner, outer, slices, loops ) + GLUquadric *quad + GLdouble inner + GLdouble outer + GLint slices + GLint loops + +void +gluPartialDisk ( quad, inner, outer, slices, loops, start, sweep ) + GLUquadric *quad + GLdouble inner + GLdouble outer + GLint slices + GLint loops + GLdouble start + GLdouble sweep + +void +gluSphere ( quad, radius, slices, stacks ) + GLUquadric *quad + GLdouble radius + GLint slices + GLint stacks + #endif