/* Last saved: Sun 06 Sep 2009 02:32:19 PM*/ /* Copyright (c) 1998 Kenneth Albanowski. All rights reserved. * Copyright (c) 2007 Bob Free. All rights reserved. * Copyright (c) 2009 Chris Marshall. All rights reserved. * This program is free software; you can redistribute it and/or * modify it under the same terms as Perl itself. */ /* OpenGL GLX bindings */ #define IN_POGL_GLX_XS #include #include "pgopogl.h" #ifdef HAVE_GL #include "gl_util.h" /* Note: this is caching procs once for all contexts */ /* !!! This should instead cache per context */ #if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_W32API)) #define loadProc(proc,name) \ { \ if (!proc) \ { \ proc = (void *)wglGetProcAddress(name); \ if (!proc) croak(name " is not supported by this renderer"); \ } \ } #define testProc(proc,name) ((proc) ? 1 : !!(proc = (void *)wglGetProcAddress(name))) #else /* not using WGL */ #define loadProc(proc,name) #define testProc(proc,name) 1 #endif /* not defined _WIN32, __CYGWIN__, and HAVE_W32API */ #endif /* defined HAVE_GL */ #ifdef HAVE_GLX #include "glx_util.h" #endif /* defined HAVE_GLX */ #ifdef HAVE_GLU #include "glu_util.h" #endif /* defined HAVE_GLU */ MODULE = OpenGL::GL::AccuGetM PACKAGE = OpenGL #ifdef HAVE_GL #// 1.0 #//# glAccum($op, $value); void glAccum(op, value) GLenum op GLfloat value #// 1.0 #//# glAlphaFunc($func, $ref); void glAlphaFunc(func, ref) GLenum func GLclampf ref #ifdef GL_VERSION_1_1 #//# glAreTexturesResident_c($n, (CPTR)textures, (CPTR)residences); void glAreTexturesResident_c(n, textures, residences) GLsizei n void * textures void * residences CODE: glAreTexturesResident(n, textures, residences); #//# glAreTexturesResident_s($n, (PACKED)textures, (PACKED)residences); void glAreTexturesResident_s(n, textures, residences) GLsizei n SV * textures SV * residences CODE: { void * textures_s = EL(textures, sizeof(GLuint)*n); void * residences_s = EL(residences, sizeof(GLboolean)*n); glAreTexturesResident(n, textures_s, residences_s); } #// 1.1 #//# (result,@residences) = glAreTexturesResident_p(@textureIDs); void glAreTexturesResident_p(...) PPCODE: { GLsizei n = items; GLuint * textures = malloc(sizeof(GLuint) * (n+1)); GLboolean * residences = malloc(sizeof(GLboolean) * (n+1)); GLboolean result; int i; for (i=0;ibind); } glColorPointer(size, oga->types[0], 0, oga->bind ? 0 : oga->data); #else glColorPointer(size, oga->types[0], 0, oga->data); #endif } #endif #// 1.0 #//# glCopyPixels($x, $y, $width, $height, $type); void glCopyPixels(x, y, width, height, type) GLint x GLint y GLsizei width GLsizei height GLenum type #ifdef GL_VERSION_1_1 #// 1.1 #//# glCopyTexImage1D($target, $level, $internalFormat, $x, $y, $width, $border); void glCopyTexImage1D(target, level, internalFormat, x, y, width, border) GLenum target GLint level GLenum internalFormat GLint x GLint y GLsizei width GLint border #// 1.1 #//# glCopyTexImage2D($target, $level, $internalFormat, $x, $y, $width, $height, $border); void glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border) GLenum target GLint level GLenum internalFormat GLint x GLint y GLsizei width GLsizei height GLint border #// 1.1 #//# glCopyTexSubImage1D($target, $level, $xoffset, $x, $y, $width); void glCopyTexSubImage1D(target, level, xoffset, x, y, width) GLenum target GLint level GLint xoffset GLint x GLint y GLsizei width #// 1.1 #//# glCopyTexSubImage2D($target, $level, $xoffset, $yoffset, $x, $y, $width, $height); void glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height) GLenum target GLint level GLint xoffset GLint yoffset GLint x GLint y GLsizei width GLsizei height #ifdef GL_VERSION_1_2 #// 1.2 #//# glCopyTexSubImage3D($target, $level, $xoffset, $yoffset, $zoffset, $x, $y, $width, $height); void glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height) GLenum target GLint level GLint xoffset GLint yoffset GLint zoffset GLint x GLint y GLsizei width GLsizei height INIT: loadProc(glCopyTexSubImage3D,"glCopyTexSubImage3D"); CODE: { glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height); } #endif #endif #// 1.0 #//# glCullFace($mode); void glCullFace(mode) GLenum mode #// 1.0 #//# glDeleteLists($list, $range); void glDeleteLists(list, range) GLenum list GLsizei range #ifdef GL_VERSION_1_1 #// 1.1 #//# glDeleteTextures_c($items, (CPTR)list); void glDeleteTextures_c(items, list) GLint items void * list CODE: glDeleteTextures(items,list); #// 1.1 #//# glDeleteTextures_s($items, (PACKED)list); void glDeleteTextures_s(items, list) GLint items SV * list CODE: { void * list_s = EL(list, sizeof(GLuint) * items); glDeleteTextures(items,list_s); } #// 1.1 #//# glDeleteTextures_p(@textureIDs); void glDeleteTextures_p(...) CODE: if (items) { GLuint * list = malloc(sizeof(GLuint) * items); int i; for(i=0;i 3) { if (start < (GLuint)items-3) { GLuint * indices; GLuint i; if (start+count > (GLuint)(items-3)) count = (GLuint)items-(start+3); indices = malloc(sizeof(GLuint) * count); for (i=start; ibind); } glEdgeFlagPointer(0, oga->bind ? 0 : oga->data); #else glEdgeFlagPointer(0, oga->data); #endif } #endif #// 1.0 #//# glEnable($cap); void glEnable(cap) GLenum cap #// 1.0 #//# glDisable($cap); void glDisable(cap) GLenum cap #ifdef GL_VERSION_1_1 #// 1.1 #//# glEnableClientState($cap); void glEnableClientState(cap) GLenum cap #// 1.1 #//# glDisableClientState($cap); void glDisableClientState(cap) GLenum cap #endif #// 1.0 #//# glEvalCoord1d($u); void glEvalCoord1d(u) GLdouble u #// 1.0 #//# glEvalCoord1f($u); void glEvalCoord1f(u) GLfloat u #// 1.0 #//# glEvalCoord2d($u, $v); void glEvalCoord2d(u, v) GLdouble u GLdouble v #// 1.0 #//# glEvalCoord2f($u, $v); void glEvalCoord2f(u, v) GLfloat u GLfloat v #// 1.0 #//# glEvalMesh1($mode, $i1, $i2); void glEvalMesh1(mode, i1, i2) GLenum mode GLint i1 GLint i2 #// 1.0 #//# glEvalMesh2($mode, $i1, $i2, $j1, $j2); void glEvalMesh2(mode, i1, i2, j1, j2) GLenum mode GLint i1 GLint i2 GLint j1 GLint j2 #// 1.0 #//# glEvalPoint1($i); void glEvalPoint1(i) GLint i #// 1.0 #//# glEvalPoint2($i, $j); void glEvalPoint2(i, j) GLint i GLint j #// 1.0 #//# glFeedbackBuffer_c($size, $type, (CPTR)buffer); void glFeedbackBuffer_c(size, type, buffer) GLsizei size GLenum type void * buffer CODE: glFeedbackBuffer(size, type, (GLfloat*)(buffer)); #// 1.0 #//# glFinish(); void glFinish() #// 1.0 #//# glFlush(); void glFlush() #// 1.0 #//# glFogf($pname, $param); void glFogf(pname, param) GLenum pname GLfloat param #// 1.0 #//# glFogi($pname, $param); void glFogi(pname, param) GLenum pname GLint param #// 1.0 #//# glFogfv_c($pname, (CPTR)params); void glFogfv_c(pname, params) GLenum pname void * params CODE: glFogfv(pname, params); #// 1.0 #//# glFogiv_c($pname, (CPTR)params); void glFogiv_c(pname, params) GLenum pname void * params CODE: glFogiv(pname, params); #// 1.0 #//# glFogfv_s($pname, (PACKED)params); void glFogfv_s(pname, params) GLenum pname SV * params CODE: { GLfloat * params_s = EL(params, sizeof(GLfloat)*gl_fog_count(pname)); glFogfv(pname, params_s); } #// 1.0 #//# glFogiv_s($pname, (PACKED)params); void glFogiv_s(pname, params) GLenum pname SV * params CODE: { GLint * params_s = EL(params, sizeof(GLint)*gl_fog_count(pname)); glFogiv(pname, params_s); } #// 1.0 #//# glFogfv_p($pname, $param1, $param2=0, $param3=0, $param4=0); void glFogfv_p(pname, param1, param2=0, param3=0, param4=0) GLenum pname GLfloat param1 GLfloat param2 GLfloat param3 GLfloat param4 CODE: { GLfloat p[4]; p[0] = param1; p[1] = param2; p[2] = param3; p[3] = param4; glFogfv(pname, &p[0]); } #// 1.0 #//# glFogiv_p($pname, $param1, $param2=0, $param3=0, $param4=0); void glFogiv_p(pname, param1, param2=0, param3=0, param4=0) GLenum pname GLint param1 GLint param2 GLint param3 GLint param4 CODE: { GLint p[4]; p[0] = param1; p[1] = param2; p[2] = param3; p[3] = param4; glFogiv(pname, &p[0]); } #// 1.0 #//# glFrontFace($mode); void glFrontFace(mode) GLenum mode #// 1.0 #//# glFrustum($left, $right, $bottom, $top, $zNear, $zFar); void glFrustum(left, right, bottom, top, zNear, zFar) GLdouble left GLdouble right GLdouble bottom GLdouble top GLdouble zNear GLdouble zFar #// 1.0 #//# glGenLists($range); GLuint glGenLists(range) GLsizei range #ifdef GL_VERSION_1_1 #// 1.1 #//# glGenTextures_c($n, (CPTR)textures); void glGenTextures_c(n, textures) GLint n void * textures CODE: glGenTextures(n, textures); #// 1.1 #//# glGenTextures_s($n, (PACKED)textures); void glGenTextures_s(n, textures) GLint n SV * textures CODE: { void * textures_s = EL(textures, sizeof(GLuint)*n); glGenTextures(n, textures_s); } #// 1.1 #//# @textureIDs = glGenTextures_p($n); void glGenTextures_p(n) GLint n PPCODE: if (n) { GLuint * textures = malloc(sizeof(GLuint) * n); int i; glGenTextures(n, textures); EXTEND(sp, n); for(i=0;i