2006-12-21 12:53:11 +00:00
|
|
|
#include "compat.h"
|
2006-04-23 06:44:19 +00:00
|
|
|
#include "glbuild.h"
|
|
|
|
#include "baselayer.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-05-12 21:55:05 +00:00
|
|
|
#if defined USE_OPENGL
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
#ifdef RENDERTYPESDL
|
2006-07-01 01:40:18 +00:00
|
|
|
# ifdef __APPLE__
|
|
|
|
# include <SDL/SDL.h>
|
|
|
|
# else
|
2006-11-13 23:12:47 +00:00
|
|
|
#include "SDL.h"
|
|
|
|
#endif
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void (APIENTRY * bglClearColor)( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
|
|
|
|
void (APIENTRY * bglClear)( GLbitfield mask );
|
|
|
|
void (APIENTRY * bglColorMask)( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha );
|
|
|
|
void (APIENTRY * bglAlphaFunc)( GLenum func, GLclampf ref );
|
|
|
|
void (APIENTRY * bglBlendFunc)( GLenum sfactor, GLenum dfactor );
|
|
|
|
void (APIENTRY * bglCullFace)( GLenum mode );
|
|
|
|
void (APIENTRY * bglFrontFace)( GLenum mode );
|
|
|
|
void (APIENTRY * bglPolygonOffset)( GLfloat factor, GLfloat units );
|
|
|
|
void (APIENTRY * bglPolygonMode)( GLenum face, GLenum mode );
|
|
|
|
void (APIENTRY * bglEnable)( GLenum cap );
|
|
|
|
void (APIENTRY * bglDisable)( GLenum cap );
|
|
|
|
void (APIENTRY * bglGetFloatv)( GLenum pname, GLfloat *params );
|
|
|
|
void (APIENTRY * bglGetIntegerv)( GLenum pname, GLint *params );
|
|
|
|
void (APIENTRY * bglPushAttrib)( GLbitfield mask );
|
|
|
|
void (APIENTRY * bglPopAttrib)( void );
|
|
|
|
GLenum (APIENTRY * bglGetError)( void );
|
|
|
|
const GLubyte* (APIENTRY * bglGetString)( GLenum name );
|
|
|
|
void (APIENTRY * bglHint)( GLenum target, GLenum mode );
|
|
|
|
|
|
|
|
// Depth
|
|
|
|
void (APIENTRY * bglDepthFunc)( GLenum func );
|
|
|
|
void (APIENTRY * bglDepthMask)( GLboolean flag );
|
|
|
|
void (APIENTRY * bglDepthRange)( GLclampd near_val, GLclampd far_val );
|
|
|
|
|
|
|
|
// Matrix
|
|
|
|
void (APIENTRY * bglMatrixMode)( GLenum mode );
|
|
|
|
void (APIENTRY * bglOrtho)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val );
|
|
|
|
void (APIENTRY * bglFrustum)( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val );
|
|
|
|
void (APIENTRY * bglViewport)( GLint x, GLint y, GLsizei width, GLsizei height );
|
|
|
|
void (APIENTRY * bglPushMatrix)( void );
|
|
|
|
void (APIENTRY * bglPopMatrix)( void );
|
|
|
|
void (APIENTRY * bglLoadIdentity)( void );
|
|
|
|
void (APIENTRY * bglLoadMatrixf)( const GLfloat *m );
|
2006-10-15 18:51:41 +00:00
|
|
|
void (APIENTRY * bglMultMatrixf)( const GLfloat *m );
|
2006-08-31 01:56:43 +00:00
|
|
|
void (APIENTRY * bglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY * bglScalef)(GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY * bglTranslatef)(GLfloat x, GLfloat y, GLfloat z);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
|
|
|
// Drawing
|
|
|
|
void (APIENTRY * bglBegin)( GLenum mode );
|
|
|
|
void (APIENTRY * bglEnd)( void );
|
|
|
|
void (APIENTRY * bglVertex2f)( GLfloat x, GLfloat y );
|
|
|
|
void (APIENTRY * bglVertex2i)( GLint x, GLint y );
|
2006-11-13 23:12:47 +00:00
|
|
|
void (APIENTRY * bglVertex3f)( GLfloat x, GLfloat y, GLfloat z );
|
2006-04-23 06:44:19 +00:00
|
|
|
void (APIENTRY * bglVertex3d)( GLdouble x, GLdouble y, GLdouble z );
|
|
|
|
void (APIENTRY * bglVertex3fv)( const GLfloat *v );
|
2006-08-31 01:56:43 +00:00
|
|
|
void (APIENTRY * bglVertex3dv)( const GLdouble *v );
|
2006-04-23 06:44:19 +00:00
|
|
|
void (APIENTRY * bglColor4f)( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
|
|
|
|
void (APIENTRY * bglColor4ub)( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha );
|
|
|
|
void (APIENTRY * bglTexCoord2d)( GLdouble s, GLdouble t );
|
|
|
|
void (APIENTRY * bglTexCoord2f)( GLfloat s, GLfloat t );
|
|
|
|
|
|
|
|
// Lighting
|
|
|
|
void (APIENTRY * bglShadeModel)( GLenum mode );
|
|
|
|
|
|
|
|
// Raster funcs
|
|
|
|
void (APIENTRY * bglReadPixels)( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels );
|
|
|
|
|
|
|
|
// Texture mapping
|
|
|
|
void (APIENTRY * bglTexEnvf)( GLenum target, GLenum pname, GLfloat param );
|
|
|
|
void (APIENTRY * bglGenTextures)( GLsizei n, GLuint *textures ); // 1.1
|
|
|
|
void (APIENTRY * bglDeleteTextures)( GLsizei n, const GLuint *textures); // 1.1
|
|
|
|
void (APIENTRY * bglBindTexture)( GLenum target, GLuint texture ); // 1.1
|
|
|
|
void (APIENTRY * bglTexImage2D)( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels );
|
2006-12-31 06:32:04 +00:00
|
|
|
void (APIENTRY * bglCopyTexImage2D)( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border );
|
|
|
|
void (APIENTRY * bglCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
2006-04-23 06:44:19 +00:00
|
|
|
void (APIENTRY * bglTexSubImage2D)( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); // 1.1
|
|
|
|
void (APIENTRY * bglTexParameterf)( GLenum target, GLenum pname, GLfloat param );
|
|
|
|
void (APIENTRY * bglTexParameteri)( GLenum target, GLenum pname, GLint param );
|
|
|
|
void (APIENTRY * bglGetTexLevelParameteriv)( GLenum target, GLint level, GLenum pname, GLint *params );
|
|
|
|
void (APIENTRY * bglCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
|
|
|
|
void (APIENTRY * bglGetCompressedTexImageARB)(GLenum, GLint, GLvoid *);
|
2006-08-31 01:56:43 +00:00
|
|
|
void (APIENTRY * bglTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
|
|
|
// Fog
|
|
|
|
void (APIENTRY * bglFogf)( GLenum pname, GLfloat param );
|
|
|
|
void (APIENTRY * bglFogi)( GLenum pname, GLint param );
|
|
|
|
void (APIENTRY * bglFogfv)( GLenum pname, const GLfloat *params );
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
// Display Lists
|
|
|
|
void (APIENTRY * bglNewList)(GLuint list, GLenum mode);
|
|
|
|
void (APIENTRY * bglEndList)(void);
|
|
|
|
void (APIENTRY * bglCallList)(GLuint list);
|
2006-12-31 06:32:04 +00:00
|
|
|
void (APIENTRY * bglDeleteLists)(GLuint list, GLsizei range);
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-09-27 02:23:27 +00:00
|
|
|
// Vertex Arrays
|
|
|
|
void (APIENTRY * bglEnableClientState)(GLenum cap);
|
|
|
|
void (APIENTRY * bglDisableClientState)(GLenum cap);
|
|
|
|
void (APIENTRY * bglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
|
|
|
void (APIENTRY * bglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
2006-09-29 21:36:12 +00:00
|
|
|
void (APIENTRY * bglDrawArrays)(GLenum mode, GLint first, GLsizei count);
|
2006-09-27 02:23:27 +00:00
|
|
|
void (APIENTRY * bglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
|
|
|
|
2006-10-04 09:54:25 +00:00
|
|
|
// Stencil Buffer
|
|
|
|
void (APIENTRY * bglClearStencil)(GLint s);
|
|
|
|
void (APIENTRY * bglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
|
|
|
|
void (APIENTRY * bglStencilFunc)(GLenum func, GLint ref, GLuint mask);
|
|
|
|
|
2006-12-31 06:32:04 +00:00
|
|
|
// GPU Programs
|
|
|
|
void (APIENTRY * bglGenProgramsARB)(GLsizei, GLuint *);
|
|
|
|
void (APIENTRY * bglBindProgramARB)(GLenum, GLuint);
|
|
|
|
void (APIENTRY * bglProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *);
|
2007-01-06 01:29:45 +00:00
|
|
|
void (APIENTRY * bglDeleteProgramsARB)(GLsizei n, const GLuint *programs);
|
2006-12-31 06:32:04 +00:00
|
|
|
|
|
|
|
// Multitexturing
|
|
|
|
void (APIENTRY * bglActiveTextureARB)(GLenum texture);
|
|
|
|
|
2007-01-06 01:29:45 +00:00
|
|
|
// Frame Buffer Objects
|
|
|
|
void (APIENTRY * bglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers);
|
|
|
|
void (APIENTRY * bglBindFramebufferEXT)(GLenum target, GLuint framebuffer);
|
|
|
|
void (APIENTRY * bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
|
|
|
GLenum (APIENTRY * bglCheckFramebufferStatusEXT)(GLenum target);
|
|
|
|
void (APIENTRY * bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
|
|
|
// Windows
|
|
|
|
HGLRC (WINAPI * bwglCreateContext)(HDC);
|
|
|
|
BOOL (WINAPI * bwglDeleteContext)(HGLRC);
|
|
|
|
PROC (WINAPI * bwglGetProcAddress)(LPCSTR);
|
|
|
|
BOOL (WINAPI * bwglMakeCurrent)(HDC,HGLRC);
|
|
|
|
|
|
|
|
BOOL (WINAPI * bwglSwapBuffers)(HDC);
|
|
|
|
int (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*);
|
|
|
|
int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR);
|
|
|
|
int (WINAPI * bwglGetPixelFormat)(HDC);
|
|
|
|
BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*);
|
|
|
|
|
|
|
|
static HANDLE hGLDLL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
char *gldriver = NULL;
|
|
|
|
|
|
|
|
static void * getproc_(const char *s, int *err, int fatal, int extension)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
void *t;
|
2006-04-23 06:44:19 +00:00
|
|
|
#if defined RENDERTYPESDL
|
2006-04-24 19:04:22 +00:00
|
|
|
t = (void*)SDL_GL_GetProcAddress(s);
|
2006-04-23 06:44:19 +00:00
|
|
|
#elif defined _WIN32
|
2006-04-24 19:04:22 +00:00
|
|
|
if (extension) t = (void*)bwglGetProcAddress(s);
|
|
|
|
else t = (void*)GetProcAddress(hGLDLL,s);
|
2006-04-23 06:44:19 +00:00
|
|
|
#else
|
|
|
|
#error Need a dynamic loader for this platform...
|
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!t && fatal) {
|
|
|
|
initprintf("Failed to find %s in %s\n", s, gldriver);
|
|
|
|
*err = 1;
|
|
|
|
}
|
|
|
|
return t;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
#define GETPROC(s) getproc_(s,&err,1,0)
|
|
|
|
#define GETPROCSOFT(s) getproc_(s,&err,0,0)
|
|
|
|
#define GETPROCEXT(s) getproc_(s,&err,1,1)
|
|
|
|
#define GETPROCEXTSOFT(s) getproc_(s,&err,0,1)
|
|
|
|
|
|
|
|
int loadgldriver(const char *driver)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
void *t;
|
|
|
|
int err=0;
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
if (hGLDLL) return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!driver) {
|
2006-11-13 23:12:47 +00:00
|
|
|
#ifdef _WIN32
|
2006-04-24 19:04:22 +00:00
|
|
|
driver = "OPENGL32.DLL";
|
2006-07-01 01:40:18 +00:00
|
|
|
#elif defined __APPLE__
|
2006-08-31 01:56:43 +00:00
|
|
|
driver = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
|
2006-04-23 06:44:19 +00:00
|
|
|
#else
|
2006-04-24 19:04:22 +00:00
|
|
|
driver = "libGL.so";
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
initprintf("Loading %s\n",driver);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
|
|
|
#if defined RENDERTYPESDL
|
2006-04-24 19:04:22 +00:00
|
|
|
if (SDL_GL_LoadLibrary(driver)) return -1;
|
2006-04-23 06:44:19 +00:00
|
|
|
#elif defined _WIN32
|
2006-04-24 19:04:22 +00:00
|
|
|
hGLDLL = LoadLibrary(driver);
|
|
|
|
if (!hGLDLL) return -1;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
gldriver = strdup(driver);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
bwglCreateContext = GETPROC("wglCreateContext");
|
|
|
|
bwglDeleteContext = GETPROC("wglDeleteContext");
|
|
|
|
bwglGetProcAddress = GETPROC("wglGetProcAddress");
|
|
|
|
bwglMakeCurrent = GETPROC("wglMakeCurrent");
|
|
|
|
|
|
|
|
bwglSwapBuffers = GETPROC("wglSwapBuffers");
|
|
|
|
bwglChoosePixelFormat = GETPROC("wglChoosePixelFormat");
|
|
|
|
bwglDescribePixelFormat = GETPROC("wglDescribePixelFormat");
|
|
|
|
bwglGetPixelFormat = GETPROC("wglGetPixelFormat");
|
|
|
|
bwglSetPixelFormat = GETPROC("wglSetPixelFormat");
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
bglClearColor = GETPROC("glClearColor");
|
|
|
|
bglClear = GETPROC("glClear");
|
|
|
|
bglColorMask = GETPROC("glColorMask");
|
|
|
|
bglAlphaFunc = GETPROC("glAlphaFunc");
|
|
|
|
bglBlendFunc = GETPROC("glBlendFunc");
|
|
|
|
bglCullFace = GETPROC("glCullFace");
|
|
|
|
bglFrontFace = GETPROC("glFrontFace");
|
|
|
|
bglPolygonOffset = GETPROC("glPolygonOffset");
|
|
|
|
bglPolygonMode = GETPROC("glPolygonMode");
|
|
|
|
bglEnable = GETPROC("glEnable");
|
|
|
|
bglDisable = GETPROC("glDisable");
|
|
|
|
bglGetFloatv = GETPROC("glGetFloatv");
|
|
|
|
bglGetIntegerv = GETPROC("glGetIntegerv");
|
|
|
|
bglPushAttrib = GETPROC("glPushAttrib");
|
|
|
|
bglPopAttrib = GETPROC("glPopAttrib");
|
|
|
|
bglGetError = GETPROC("glGetError");
|
|
|
|
bglGetString = GETPROC("glGetString");
|
|
|
|
bglHint = GETPROC("glHint");
|
|
|
|
|
|
|
|
// Depth
|
|
|
|
bglDepthFunc = GETPROC("glDepthFunc");
|
|
|
|
bglDepthMask = GETPROC("glDepthMask");
|
|
|
|
bglDepthRange = GETPROC("glDepthRange");
|
|
|
|
|
|
|
|
// Matrix
|
|
|
|
bglMatrixMode = GETPROC("glMatrixMode");
|
|
|
|
bglOrtho = GETPROC("glOrtho");
|
|
|
|
bglFrustum = GETPROC("glFrustum");
|
|
|
|
bglViewport = GETPROC("glViewport");
|
|
|
|
bglPushMatrix = GETPROC("glPushMatrix");
|
|
|
|
bglPopMatrix = GETPROC("glPopMatrix");
|
|
|
|
bglLoadIdentity = GETPROC("glLoadIdentity");
|
|
|
|
bglLoadMatrixf = GETPROC("glLoadMatrixf");
|
2006-10-15 18:51:41 +00:00
|
|
|
bglMultMatrixf = GETPROC("glMultMatrixf");
|
2006-08-29 01:58:59 +00:00
|
|
|
bglRotatef = GETPROC("glRotatef");
|
2006-08-30 23:32:39 +00:00
|
|
|
bglScalef = GETPROC("glScalef");
|
|
|
|
bglTranslatef = GETPROC("glTranslatef");
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Drawing
|
2007-01-06 01:29:45 +00:00
|
|
|
bglBegin = GETPROC("glBegin");
|
|
|
|
bglEnd = GETPROC("glEnd");
|
|
|
|
bglVertex2f = GETPROC("glVertex2f");
|
|
|
|
bglVertex2i = GETPROC("glVertex2i");
|
|
|
|
bglVertex3f = GETPROC("glVertex3f");
|
|
|
|
bglVertex3d = GETPROC("glVertex3d");
|
|
|
|
bglVertex3fv = GETPROC("glVertex3fv");
|
|
|
|
bglVertex3dv = GETPROC("glVertex3dv");
|
|
|
|
bglColor4f = GETPROC("glColor4f");
|
|
|
|
bglColor4ub = GETPROC("glColor4ub");
|
|
|
|
bglTexCoord2d = GETPROC("glTexCoord2d");
|
|
|
|
bglTexCoord2f = GETPROC("glTexCoord2f");
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Lighting
|
|
|
|
bglShadeModel = GETPROC("glShadeModel");
|
|
|
|
|
|
|
|
// Raster funcs
|
|
|
|
bglReadPixels = GETPROC("glReadPixels");
|
|
|
|
|
|
|
|
// Texture mapping
|
2007-01-06 01:29:45 +00:00
|
|
|
bglTexEnvf = GETPROC("glTexEnvf");
|
2006-04-24 19:04:22 +00:00
|
|
|
bglGenTextures = GETPROC("glGenTextures");
|
|
|
|
bglDeleteTextures = GETPROC("glDeleteTextures");
|
|
|
|
bglBindTexture = GETPROC("glBindTexture");
|
|
|
|
bglTexImage2D = GETPROC("glTexImage2D");
|
2006-12-31 06:32:04 +00:00
|
|
|
bglCopyTexImage2D = GETPROC("glCopyTexImage2D");
|
|
|
|
bglCopyTexSubImage2D= GETPROC("glCopyTexSubImage2D");
|
2006-04-24 19:04:22 +00:00
|
|
|
bglTexSubImage2D = GETPROC("glTexSubImage2D");
|
|
|
|
bglTexParameterf = GETPROC("glTexParameterf");
|
|
|
|
bglTexParameteri = GETPROC("glTexParameteri");
|
|
|
|
bglGetTexLevelParameteriv = GETPROC("glGetTexLevelParameteriv");
|
2006-08-31 01:56:43 +00:00
|
|
|
bglTexGenfv = GETPROC("glTexGenfv");
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Fog
|
|
|
|
bglFogf = GETPROC("glFogf");
|
|
|
|
bglFogi = GETPROC("glFogi");
|
|
|
|
bglFogfv = GETPROC("glFogfv");
|
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
// Display Lists
|
2007-01-06 01:29:45 +00:00
|
|
|
bglNewList = GETPROC("glNewList");
|
|
|
|
bglEndList = GETPROC("glEndList");
|
|
|
|
bglCallList = GETPROC("glCallList");
|
|
|
|
bglDeleteLists = GETPROC("glDeleteLists");
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2006-09-27 02:23:27 +00:00
|
|
|
// Vertex Arrays
|
|
|
|
bglEnableClientState = GETPROC("glEnableClientState");
|
|
|
|
bglDisableClientState = GETPROC("glDisableClientState");
|
|
|
|
bglVertexPointer = GETPROC("glVertexPointer");
|
|
|
|
bglTexCoordPointer = GETPROC("glTexCoordPointer");
|
2006-09-29 21:36:12 +00:00
|
|
|
bglDrawArrays = GETPROC("glDrawArrays");
|
2006-09-27 02:23:27 +00:00
|
|
|
bglDrawElements = GETPROC("glDrawElements");
|
|
|
|
|
2006-10-04 09:54:25 +00:00
|
|
|
// Stencil Buffer
|
|
|
|
bglClearStencil = GETPROC("glClearStencil");
|
|
|
|
bglStencilOp = GETPROC("glStencilOp");
|
|
|
|
bglStencilFunc = GETPROC("glStencilFunc");
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
loadglextensions();
|
|
|
|
|
|
|
|
if (err) unloadgldriver();
|
|
|
|
return err;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int loadglextensions(void)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
int err = 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!hGLDLL) return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
bglCompressedTexImage2DARB = GETPROCEXTSOFT("glCompressedTexImage2DARB");
|
|
|
|
bglGetCompressedTexImageARB = GETPROCEXTSOFT("glGetCompressedTexImageARB");
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-12-31 06:32:04 +00:00
|
|
|
// GPU Programs
|
|
|
|
bglGenProgramsARB = GETPROCEXTSOFT("glGenProgramsARB");
|
|
|
|
bglBindProgramARB = GETPROCEXTSOFT("glBindProgramARB");
|
|
|
|
bglProgramStringARB = GETPROCEXTSOFT("glProgramStringARB");
|
2007-01-06 01:29:45 +00:00
|
|
|
bglDeleteProgramsARB= GETPROCEXTSOFT("glDeleteProgramsARB");
|
2006-12-31 06:32:04 +00:00
|
|
|
|
|
|
|
// Multitexturing
|
|
|
|
bglActiveTextureARB = GETPROCEXTSOFT("glActiveTextureARB");
|
|
|
|
|
2007-01-06 01:29:45 +00:00
|
|
|
// Frame Buffer Objects
|
|
|
|
bglGenFramebuffersEXT = GETPROCEXTSOFT("glGenFramebuffersEXT");
|
|
|
|
bglBindFramebufferEXT = GETPROCEXTSOFT("glBindFramebufferEXT");
|
|
|
|
bglFramebufferTexture2DEXT = GETPROCEXTSOFT("glFramebufferTexture2DEXT");
|
|
|
|
bglCheckFramebufferStatusEXT = GETPROCEXTSOFT("glCheckFramebufferStatusEXT");
|
|
|
|
bglDeleteFramebuffersEXT = GETPROCEXTSOFT("glDeleteFramebuffersEXT");
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return err;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int unloadgldriver(void)
|
|
|
|
{
|
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!hGLDLL) return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
free(gldriver);
|
|
|
|
gldriver = NULL;
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
FreeLibrary(hGLDLL);
|
|
|
|
hGLDLL = NULL;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
bglClearColor = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglClear = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglColorMask = NULL;
|
|
|
|
bglAlphaFunc = NULL;
|
|
|
|
bglBlendFunc = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglCullFace = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglFrontFace = NULL;
|
|
|
|
bglPolygonOffset = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglPolygonMode = NULL;
|
|
|
|
bglEnable = NULL;
|
|
|
|
bglDisable = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglGetFloatv = NULL;
|
|
|
|
bglGetIntegerv = NULL;
|
|
|
|
bglPushAttrib = NULL;
|
|
|
|
bglPopAttrib = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglGetError = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglGetString = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglHint = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Depth
|
|
|
|
bglDepthFunc = NULL;
|
|
|
|
bglDepthMask = NULL;
|
|
|
|
bglDepthRange = NULL;
|
|
|
|
|
|
|
|
// Matrix
|
|
|
|
bglMatrixMode = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglOrtho = NULL;
|
|
|
|
bglFrustum = NULL;
|
|
|
|
bglViewport = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglPushMatrix = NULL;
|
|
|
|
bglPopMatrix = NULL;
|
|
|
|
bglLoadIdentity = NULL;
|
|
|
|
bglLoadMatrixf = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglMultMatrixf = NULL;
|
|
|
|
bglRotatef = NULL;
|
|
|
|
bglScalef = NULL;
|
|
|
|
bglTranslatef = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Drawing
|
|
|
|
bglBegin = NULL;
|
|
|
|
bglEnd = NULL;
|
|
|
|
bglVertex2f = NULL;
|
|
|
|
bglVertex2i = NULL;
|
2006-10-18 03:59:28 +00:00
|
|
|
bglVertex3f = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglVertex3d = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglVertex3fv = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglColor4f = NULL;
|
|
|
|
bglColor4ub = NULL;
|
2006-10-15 18:51:41 +00:00
|
|
|
bglTexCoord2d = NULL;
|
|
|
|
bglTexCoord2f = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
// Lighting
|
|
|
|
bglShadeModel = NULL;
|
|
|
|
|
|
|
|
// Raster funcs
|
|
|
|
bglReadPixels = NULL;
|
|
|
|
|
|
|
|
// Texture mapping
|
2006-10-15 18:51:41 +00:00
|
|
|
bglTexEnvf = NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglGenTextures = NULL;
|
|
|
|
bglDeleteTextures = NULL;
|
|
|
|
bglBindTexture = NULL;
|
|
|
|
bglTexImage2D = NULL;
|
2006-12-31 06:32:04 +00:00
|
|
|
bglCopyTexImage2D = NULL;
|
|
|
|
bglCopyTexSubImage2D= NULL;
|
2006-04-24 19:04:22 +00:00
|
|
|
bglTexSubImage2D = NULL;
|
|
|
|
bglTexParameterf = NULL;
|
|
|
|
bglTexParameteri = NULL;
|
|
|
|
bglGetTexLevelParameteriv = NULL;
|
|
|
|
bglCompressedTexImage2DARB = NULL;
|
|
|
|
bglGetCompressedTexImageARB = NULL;
|
|
|
|
|
|
|
|
// Fog
|
|
|
|
bglFogf = NULL;
|
|
|
|
bglFogi = NULL;
|
|
|
|
bglFogfv = NULL;
|
|
|
|
|
2006-09-27 02:23:27 +00:00
|
|
|
// Display Lists
|
2006-10-15 18:51:41 +00:00
|
|
|
bglNewList = NULL;
|
|
|
|
bglEndList = NULL;
|
|
|
|
bglCallList = NULL;
|
2006-12-31 06:32:04 +00:00
|
|
|
bglDeleteLists = NULL;
|
2006-09-27 02:23:27 +00:00
|
|
|
|
|
|
|
// Vertex Arrays
|
|
|
|
bglEnableClientState = NULL;
|
|
|
|
bglDisableClientState = NULL;
|
|
|
|
bglVertexPointer = NULL;
|
|
|
|
bglTexCoordPointer = NULL;
|
|
|
|
bglDrawElements = NULL;
|
|
|
|
|
2006-10-04 09:54:25 +00:00
|
|
|
// Stencil Buffer
|
|
|
|
bglClearStencil = NULL;
|
|
|
|
bglStencilOp = NULL;
|
|
|
|
bglStencilFunc = NULL;
|
|
|
|
|
2006-12-31 06:32:04 +00:00
|
|
|
// GPU Programs
|
|
|
|
bglGenProgramsARB = NULL;
|
|
|
|
bglBindProgramARB = NULL;
|
|
|
|
bglProgramStringARB = NULL;
|
2007-01-06 01:29:45 +00:00
|
|
|
bglDeleteProgramsARB= NULL;
|
2006-12-31 06:32:04 +00:00
|
|
|
|
|
|
|
// Multitexturing
|
|
|
|
bglActiveTextureARB = NULL;
|
|
|
|
|
2007-01-06 01:29:45 +00:00
|
|
|
// Frame Buffer Objects
|
|
|
|
bglGenFramebuffersEXT = NULL;
|
|
|
|
bglBindFramebufferEXT = NULL;
|
|
|
|
bglFramebufferTexture2DEXT = NULL;
|
|
|
|
bglCheckFramebufferStatusEXT = NULL;
|
|
|
|
bglDeleteFramebuffersEXT = NULL;
|
|
|
|
|
2006-04-23 06:44:19 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
2006-04-24 19:04:22 +00:00
|
|
|
bwglCreateContext = NULL;
|
|
|
|
bwglDeleteContext = NULL;
|
|
|
|
bwglGetProcAddress = NULL;
|
|
|
|
bwglMakeCurrent = NULL;
|
|
|
|
|
|
|
|
bwglSwapBuffers = NULL;
|
|
|
|
bwglChoosePixelFormat = NULL;
|
|
|
|
bwglDescribePixelFormat = NULL;
|
|
|
|
bwglGetPixelFormat = NULL;
|
|
|
|
bwglSetPixelFormat = NULL;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|