-// SDL::OpenGL
//
-// Copyright (C) 2002,2003,2004 David J. Goehrig
+// OpenGL.xs
+//
+// Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
+//
+// ------------------------------------------------------------------------------
+//
+// 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"
#include <SDL.h>
+#ifdef PERL_DARWIN
#include <gl.h>
#include <glu.h>
+#else
+#include <GL/gl.h>
+
+#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 <GL/glext.h>
+#undef GL_VERSION_1_3
+#undef GL_VERSION_1_2
+#endif
+
+#include <GL/glu.h>
+#endif
+
#ifdef USE_THREADS
#define HAVE_TLS_CONTEXT
#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
case GL_MAX_ATTRIB_STACK_DEPTH:
case GL_POLYGON_SMOOTH_HINT:
case GL_ACCUM_GREEN_BITS:
- case GL_MAX_TEXTURE_UNITS_ARB:
{
GLint ret[1];
int i;
CODE:
glDrawElements( mode, count, type, indices);
+#ifdef GL_VERSION_1_2
+
void
glDrawRangeElements ( mode, start, end, count, type, indices )
GLenum mode
CODE:
glDrawRangeElements(mode,start,end,count,type,indices);
+#endif // GL_VERSION_1_2
+
void
glDrawArrays ( mode, first, count )
GLenum mode
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);
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);
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);
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 ) {
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 ) {
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++ ) {
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));
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++ ) {
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);
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
CODE:
gluNurbsCallbackData(obj,(void*)cb);
+#endif
+
void
gluBeginSurface ( obj )
GLUnurbsObj *obj
#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