Removed dynamic OpenGL code from Windows and updated extensions.

This commit is contained in:
leo 2012-04-13 02:00:45 +00:00
parent 067838dfd8
commit e3c5d73abe
13 changed files with 222 additions and 701 deletions

View file

@ -16,6 +16,7 @@ void* Sys_GLGetExtension (const char *symbol);
// ============================================================================= // =============================================================================
// OpenGL Function pointers // OpenGL Function pointers
#ifdef LC_OPENGL_DYNAMIC
PFNGLCLEARINDEX pfnglClearIndex; PFNGLCLEARINDEX pfnglClearIndex;
PFNGLCLEARCOLOR pfnglClearColor; PFNGLCLEARCOLOR pfnglClearColor;
PFNGLCLEAR pfnglClear; PFNGLCLEAR pfnglClear;
@ -352,45 +353,19 @@ PFNGLINITNAMES pfnglInitNames;
PFNGLLOADNAME pfnglLoadName; PFNGLLOADNAME pfnglLoadName;
PFNGLPUSHNAME pfnglPushName; PFNGLPUSHNAME pfnglPushName;
PFNGLPOPNAME pfnglPopName; PFNGLPOPNAME pfnglPopName;
#endif // LC_OPENGL_DYNAMIC
PFNGLACTIVETEXTUREARB pfnglActiveTextureARB; GLBINDBUFFERARBPROC glBindBufferARB;
PFNGLCLIENTACTIVETEXTUREARB pfnglClientActiveTextureARB; GLDELETEBUFFERSARBPROC glDeleteBuffersARB;
PFNGLMULTITEXCOORD1DARB pfnglMultiTexCoord1dARB; GLGENBUFFERSARBPROC glGenBuffersARB;
PFNGLMULTITEXCOORD1DVARB pfnglMultiTexCoord1dvARB; GLISBUFFERARBPROC glIsBufferARB;
PFNGLMULTITEXCOORD1FARB pfnglMultiTexCoord1fARB; GLBUFFERDATAARBPROC glBufferDataARB;
PFNGLMULTITEXCOORD1FVARB pfnglMultiTexCoord1fvARB; GLBUFFERSUBDATAARBPROC glBufferSubDataARB;
PFNGLMULTITEXCOORD1IARB pfnglMultiTexCoord1iARB; GLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB;
PFNGLMULTITEXCOORD1IVARB pfnglMultiTexCoord1ivARB; GLMAPBUFFERARBPROC glMapBufferARB;
PFNGLMULTITEXCOORD1SARB pfnglMultiTexCoord1sARB; GLUNMAPBUFFERARBPROC glUnmapBufferARB;
PFNGLMULTITEXCOORD1SVARB pfnglMultiTexCoord1svARB; GLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB;
PFNGLMULTITEXCOORD2DARB pfnglMultiTexCoord2dARB; GLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
PFNGLMULTITEXCOORD2DVARB pfnglMultiTexCoord2dvARB;
PFNGLMULTITEXCOORD2FARB pfnglMultiTexCoord2fARB;
PFNGLMULTITEXCOORD2FVARB pfnglMultiTexCoord2fvARB;
PFNGLMULTITEXCOORD2IARB pfnglMultiTexCoord2iARB;
PFNGLMULTITEXCOORD2IVARB pfnglMultiTexCoord2ivARB;
PFNGLMULTITEXCOORD2SARB pfnglMultiTexCoord2sARB;
PFNGLMULTITEXCOORD2SVARB pfnglMultiTexCoord2svARB;
PFNGLMULTITEXCOORD3DARB pfnglMultiTexCoord3dARB;
PFNGLMULTITEXCOORD3DVARB pfnglMultiTexCoord3dvARB;
PFNGLMULTITEXCOORD3FARB pfnglMultiTexCoord3fARB;
PFNGLMULTITEXCOORD3FVARB pfnglMultiTexCoord3fvARB;
PFNGLMULTITEXCOORD3IARB pfnglMultiTexCoord3iARB;
PFNGLMULTITEXCOORD3IVARB pfnglMultiTexCoord3ivARB;
PFNGLMULTITEXCOORD3SARB pfnglMultiTexCoord3sARB;
PFNGLMULTITEXCOORD3SVARB pfnglMultiTexCoord3svARB;
PFNGLMULTITEXCOORD4DARB pfnglMultiTexCoord4dARB;
PFNGLMULTITEXCOORD4DVARB pfnglMultiTexCoord4dvARB;
PFNGLMULTITEXCOORD4FARB pfnglMultiTexCoord4fARB;
PFNGLMULTITEXCOORD4FVARB pfnglMultiTexCoord4fvARB;
PFNGLMULTITEXCOORD4IARB pfnglMultiTexCoord4iARB;
PFNGLMULTITEXCOORD4IVARB pfnglMultiTexCoord4ivARB;
PFNGLMULTITEXCOORD4SARB pfnglMultiTexCoord4sARB;
PFNGLMULTITEXCOORD4SVARB pfnglMultiTexCoord4svARB;
PFNGLPOINTPARAMETERFEXT pfnglPointParameterfEXT;
PFNGLPOINTPARAMETERFVEXT pfnglPointParameterfvEXT;
PFNGLLOCKARRAYSEXT pfnglLockArraysEXT;
PFNGLUNLOCKARRAYSEXT pfnglUnlockArraysEXT;
// ============================================================================= // =============================================================================
// Initialization functions // Initialization functions
@ -399,6 +374,7 @@ void GL_Shutdown ()
{ {
Sys_GLCloseLibrary (); Sys_GLCloseLibrary ();
#ifdef LC_OPENGL_DYNAMIC
pfnglClearIndex = NULL; pfnglClearIndex = NULL;
pfnglClearColor = NULL; pfnglClearColor = NULL;
pfnglClear = NULL; pfnglClear = NULL;
@ -735,45 +711,19 @@ void GL_Shutdown ()
pfnglLoadName = NULL; pfnglLoadName = NULL;
pfnglPushName = NULL; pfnglPushName = NULL;
pfnglPopName = NULL; pfnglPopName = NULL;
#endif // LC_OPENGL_DYNAMIC
pfnglActiveTextureARB = NULL; glBindBufferARB = NULL;
pfnglClientActiveTextureARB = NULL; glDeleteBuffersARB = NULL;
pfnglMultiTexCoord1dARB = NULL; glGenBuffersARB = NULL;
pfnglMultiTexCoord1dvARB = NULL; glIsBufferARB = NULL;
pfnglMultiTexCoord1fARB = NULL; glBufferDataARB = NULL;
pfnglMultiTexCoord1fvARB = NULL; glBufferSubDataARB = NULL;
pfnglMultiTexCoord1iARB = NULL; glGetBufferSubDataARB = NULL;
pfnglMultiTexCoord1ivARB = NULL; glMapBufferARB = NULL;
pfnglMultiTexCoord1sARB = NULL; glUnmapBufferARB = NULL;
pfnglMultiTexCoord1svARB = NULL; glGetBufferParameterivARB = NULL;
pfnglMultiTexCoord2dARB = NULL; glGetBufferPointervARB = NULL;
pfnglMultiTexCoord2dvARB = NULL;
pfnglMultiTexCoord2fARB = NULL;
pfnglMultiTexCoord2fvARB = NULL;
pfnglMultiTexCoord2iARB = NULL;
pfnglMultiTexCoord2ivARB = NULL;
pfnglMultiTexCoord2sARB = NULL;
pfnglMultiTexCoord2svARB = NULL;
pfnglMultiTexCoord3dARB = NULL;
pfnglMultiTexCoord3dvARB = NULL;
pfnglMultiTexCoord3fARB = NULL;
pfnglMultiTexCoord3fvARB = NULL;
pfnglMultiTexCoord3iARB = NULL;
pfnglMultiTexCoord3ivARB = NULL;
pfnglMultiTexCoord3sARB = NULL;
pfnglMultiTexCoord3svARB = NULL;
pfnglMultiTexCoord4dARB = NULL;
pfnglMultiTexCoord4dvARB = NULL;
pfnglMultiTexCoord4fARB = NULL;
pfnglMultiTexCoord4fvARB = NULL;
pfnglMultiTexCoord4iARB = NULL;
pfnglMultiTexCoord4ivARB = NULL;
pfnglMultiTexCoord4sARB = NULL;
pfnglMultiTexCoord4svARB = NULL;
pfnglPointParameterfEXT = NULL;
pfnglPointParameterfvEXT = NULL;
pfnglLockArraysEXT = NULL;
pfnglUnlockArraysEXT = NULL;
} }
bool GL_Initialize (const char* libname) bool GL_Initialize (const char* libname)
@ -784,6 +734,7 @@ bool GL_Initialize (const char* libname)
return false; return false;
} }
#ifdef LC_OPENGL_DYNAMIC
pfnglClearIndex = (PFNGLCLEARINDEX) Sys_GLGetProc ("glClearIndex"); pfnglClearIndex = (PFNGLCLEARINDEX) Sys_GLGetProc ("glClearIndex");
pfnglClearColor = (PFNGLCLEARCOLOR) Sys_GLGetProc ("glClearColor"); pfnglClearColor = (PFNGLCLEARCOLOR) Sys_GLGetProc ("glClearColor");
pfnglClear = (PFNGLCLEAR) Sys_GLGetProc ("glClear"); pfnglClear = (PFNGLCLEAR) Sys_GLGetProc ("glClear");
@ -1120,6 +1071,7 @@ bool GL_Initialize (const char* libname)
pfnglLoadName = (PFNGLLOADNAME) Sys_GLGetProc ("glLoadName"); pfnglLoadName = (PFNGLLOADNAME) Sys_GLGetProc ("glLoadName");
pfnglPushName = (PFNGLPUSHNAME) Sys_GLGetProc ("glPushName"); pfnglPushName = (PFNGLPUSHNAME) Sys_GLGetProc ("glPushName");
pfnglPopName = (PFNGLPOPNAME) Sys_GLGetProc ("glPopName"); pfnglPopName = (PFNGLPOPNAME) Sys_GLGetProc ("glPopName");
#endif // LC_OPENGL_DYNAMIC
return true; return true;
} }
@ -1127,10 +1079,7 @@ bool GL_Initialize (const char* libname)
// ============================================================================= // =============================================================================
// Extensions support // Extensions support
static GLint GL_MultiTextures = 1; bool GL_VertexBufferObject = false;
static bool GL_CompiledVertexArrays = false;
static bool GL_ClampToEdge = false;
static bool GL_PointParameters = false;
static bool GL_ExtensionSupported (const char *extension) static bool GL_ExtensionSupported (const char *extension)
{ {
@ -1167,85 +1116,23 @@ static bool GL_ExtensionSupported (const char *extension)
return false; return false;
} }
int GL_GetMultiTextures ()
{
return GL_MultiTextures;
}
bool GL_HasCompiledVertexArrays ()
{
return GL_CompiledVertexArrays;
}
bool GL_HasClampToEdge ()
{
return GL_ClampToEdge;
}
bool GL_HasPointParameters ()
{
return GL_PointParameters;
}
// Extensions can only be initialized if there's a current OpenGL context. // Extensions can only be initialized if there's a current OpenGL context.
bool GL_InitializeExtensions() bool GL_InitializeExtensions()
{ {
if (GL_ExtensionSupported ("GL_ARB_multitexture")) if (GL_ExtensionSupported("GL_ARB_vertex_buffer_object"))
{ {
pfnglActiveTextureARB = (PFNGLACTIVETEXTUREARB) Sys_GLGetExtension ("glActiveTextureARB"); glBindBufferARB = (GLBINDBUFFERARBPROC)Sys_GLGetExtension("glBindBufferARB");
pfnglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARB) Sys_GLGetExtension ("glClientActiveTextureARB"); glDeleteBuffersARB = (GLDELETEBUFFERSARBPROC)Sys_GLGetExtension("glDeleteBuffersARB");
pfnglMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARB) Sys_GLGetExtension ("glMultiTexCoord1dARB"); glGenBuffersARB = (GLGENBUFFERSARBPROC)Sys_GLGetExtension("glGenBuffersARB");
pfnglMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARB) Sys_GLGetExtension ("glMultiTexCoord1dvARB"); glIsBufferARB = (GLISBUFFERARBPROC)Sys_GLGetExtension("glIsBufferARB");
pfnglMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARB) Sys_GLGetExtension ("glMultiTexCoord1fARB"); glBufferDataARB = (GLBUFFERDATAARBPROC)Sys_GLGetExtension("glBufferDataARB");
pfnglMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARB) Sys_GLGetExtension ("glMultiTexCoord1fvARB"); glBufferSubDataARB = (GLBUFFERSUBDATAARBPROC)Sys_GLGetExtension("glBufferSubDataARB");
pfnglMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARB) Sys_GLGetExtension ("glMultiTexCoord1iARB"); glGetBufferSubDataARB = (GLGETBUFFERSUBDATAARBPROC)Sys_GLGetExtension("glGetBufferSubDataARB");
pfnglMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARB) Sys_GLGetExtension ("glMultiTexCoord1ivARB"); glMapBufferARB = (GLMAPBUFFERARBPROC)Sys_GLGetExtension("glMapBufferARB");
pfnglMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARB) Sys_GLGetExtension ("glMultiTexCoord1sARB"); glUnmapBufferARB = (GLUNMAPBUFFERARBPROC)Sys_GLGetExtension("glUnmapBufferARB");
pfnglMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARB) Sys_GLGetExtension ("glMultiTexCoord1svARB"); glGetBufferParameterivARB = (GLGETBUFFERPARAMETERIVARBPROC)Sys_GLGetExtension("glGetBufferParameterivARB");
pfnglMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARB) Sys_GLGetExtension ("glMultiTexCoord2dARB"); glGetBufferPointervARB = (GLGETBUFFERPOINTERVARBPROC)Sys_GLGetExtension("glGetBufferPointervARB");
pfnglMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARB) Sys_GLGetExtension ("glMultiTexCoord2dvARB"); GL_VertexBufferObject = true;
pfnglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARB) Sys_GLGetExtension ("glMultiTexCoord2fARB");
pfnglMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARB) Sys_GLGetExtension ("glMultiTexCoord2fvARB");
pfnglMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARB) Sys_GLGetExtension ("glMultiTexCoord2iARB");
pfnglMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARB) Sys_GLGetExtension ("glMultiTexCoord2ivARB");
pfnglMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARB) Sys_GLGetExtension ("glMultiTexCoord2sARB");
pfnglMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARB) Sys_GLGetExtension ("glMultiTexCoord2svARB");
pfnglMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARB) Sys_GLGetExtension ("glMultiTexCoord3dARB");
pfnglMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARB) Sys_GLGetExtension ("glMultiTexCoord3dvARB");
pfnglMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARB) Sys_GLGetExtension ("glMultiTexCoord3fARB");
pfnglMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARB) Sys_GLGetExtension ("glMultiTexCoord3fvARB");
pfnglMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARB) Sys_GLGetExtension ("glMultiTexCoord3iARB");
pfnglMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARB) Sys_GLGetExtension ("glMultiTexCoord3ivARB");
pfnglMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARB) Sys_GLGetExtension ("glMultiTexCoord3sARB");
pfnglMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARB) Sys_GLGetExtension ("glMultiTexCoord3svARB");
pfnglMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARB) Sys_GLGetExtension ("glMultiTexCoord4dARB");
pfnglMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARB) Sys_GLGetExtension ("glMultiTexCoord4dvARB");
pfnglMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARB) Sys_GLGetExtension ("glMultiTexCoord4fARB");
pfnglMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARB) Sys_GLGetExtension ("glMultiTexCoord4fvARB");
pfnglMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARB) Sys_GLGetExtension ("glMultiTexCoord4iARB");
pfnglMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARB) Sys_GLGetExtension ("glMultiTexCoord4ivARB");
pfnglMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARB) Sys_GLGetExtension ("glMultiTexCoord4sARB");
pfnglMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARB) Sys_GLGetExtension ("glMultiTexCoord4svARB");
glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &GL_MultiTextures);
}
if (GL_ExtensionSupported ("GL_EXT_point_parameters"))
{
pfnglPointParameterfEXT = (PFNGLPOINTPARAMETERFEXT) Sys_GLGetExtension ("glPointParameterfEXT");
pfnglPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXT) Sys_GLGetExtension ("glPointParameterfvEXT");
GL_PointParameters = true;
}
if (GL_ExtensionSupported ("GL_EXT_compiled_vertex_array"))
{
pfnglLockArraysEXT = (PFNGLLOCKARRAYSEXT) Sys_GLGetExtension ("glLockArraysEXT");
pfnglUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXT) Sys_GLGetExtension ("glUnlockArraysEXT");
GL_CompiledVertexArrays = true;
}
if (GL_ExtensionSupported ("GL_EXT_texture_edge_clamp"))
{
GL_ClampToEdge = true;
} }
return true; return true;

View file

@ -1,17 +1,11 @@
#ifndef _OPENGL_H_ #ifndef _OPENGL_H_
#define _OPENGL_H_ #define _OPENGL_H_
#ifdef LC_WINDOWS
#include <GL/gl.h>
#include "win_gl.h"
#else
#define APIENTRY
#endif
#ifdef LC_LINUX #ifdef LC_LINUX
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glx.h> #include <GL/glx.h>
#include "linux_gl.h" #include "linux_gl.h"
#define LC_OPENGL_DYNAMIC 1
#endif #endif
#ifdef LC_MACOSX #ifdef LC_MACOSX
@ -19,7 +13,10 @@
#include <AGL/agl.h> #include <AGL/agl.h>
#endif #endif
//#include <GL/glu.h> // TODO: remove all glu calls #ifndef APIENTRY
#define APIENTRY
#endif
void gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, void gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble centerx, GLdouble centery, GLdouble centerz,
GLdouble upx, GLdouble upy, GLdouble upz); GLdouble upx, GLdouble upy, GLdouble upz);
@ -29,14 +26,17 @@ bool GL_Initialize (const char* libname);
void GL_Shutdown(); void GL_Shutdown();
bool GL_InitializeExtensions(); bool GL_InitializeExtensions();
int GL_GetMultiTextures (); inline bool GL_HasVertexBufferObject()
bool GL_HasCompiledVertexArrays (); {
bool GL_HasClampToEdge (); extern bool GL_VertexBufferObject;
bool GL_HasPointParameters (); return GL_VertexBufferObject;
}
// ============================================================================= // =============================================================================
// OpenGL functions typedefs // OpenGL functions typedefs
#ifdef LC_OPENGL_DYNAMIC
// Miscellaneous // Miscellaneous
typedef void (APIENTRY *PFNGLCLEARINDEX) (GLfloat c); typedef void (APIENTRY *PFNGLCLEARINDEX) (GLfloat c);
typedef void (APIENTRY *PFNGLCLEARCOLOR) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (APIENTRY *PFNGLCLEARCOLOR) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
@ -401,112 +401,76 @@ typedef void (APIENTRY *PFNGLLOADNAME) (GLuint name);
typedef void (APIENTRY *PFNGLPUSHNAME) (GLuint name); typedef void (APIENTRY *PFNGLPUSHNAME) (GLuint name);
typedef void (APIENTRY *PFNGLPOPNAME) (void); typedef void (APIENTRY *PFNGLPOPNAME) (void);
// GL_ARB_multitexture #endif // LC_OPENGL_DYNAMIC
typedef void (APIENTRY *PFNGLACTIVETEXTUREARB) (GLenum texture);
typedef void (APIENTRY *PFNGLCLIENTACTIVETEXTUREARB) (GLenum texture);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1DARB) (GLenum target, GLdouble s);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1DVARB) (GLenum target, const GLdouble *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1FARB) (GLenum target, GLfloat s);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1FVARB) (GLenum target, const GLfloat *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1IARB) (GLenum target, GLint s);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1IVARB) (GLenum target, const GLint *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1SARB) (GLenum target, GLshort s);
typedef void (APIENTRY *PFNGLMULTITEXCOORD1SVARB) (GLenum target, const GLshort *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2DARB) (GLenum target, GLdouble s, GLdouble t);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2DVARB) (GLenum target, const GLdouble *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2FARB) (GLenum target, GLfloat s, GLfloat t);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2FVARB) (GLenum target, const GLfloat *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2IARB) (GLenum target, GLint s, GLint t);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2IVARB) (GLenum target, const GLint *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2SARB) (GLenum target, GLshort s, GLshort t);
typedef void (APIENTRY *PFNGLMULTITEXCOORD2SVARB) (GLenum target, const GLshort *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3DARB) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3DVARB) (GLenum target, const GLdouble *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3FARB) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3FVARB) (GLenum target, const GLfloat *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3IARB) (GLenum target, GLint s, GLint t, GLint r);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3IVARB) (GLenum target, const GLint *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3SARB) (GLenum target, GLshort s, GLshort t, GLshort r);
typedef void (APIENTRY *PFNGLMULTITEXCOORD3SVARB) (GLenum target, const GLshort *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4DARB) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4DVARB) (GLenum target, const GLdouble *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4FARB) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4FVARB) (GLenum target, const GLfloat *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4IARB) (GLenum target, GLint s, GLint t, GLint r, GLint q);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4IVARB) (GLenum target, const GLint *v);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4SARB) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
typedef void (APIENTRY *PFNGLMULTITEXCOORD4SVARB) (GLenum target, const GLshort *v);
#ifndef GL_ARB_multitexture #include <stddef.h>
#define GL_TEXTURE0_ARB 0x84C0 #ifndef GL_VERSION_1_5
#define GL_TEXTURE1_ARB 0x84C1 // GL types for handling large vertex buffer objects
#define GL_TEXTURE2_ARB 0x84C2 typedef ptrdiff_t GLintptr;
#define GL_TEXTURE3_ARB 0x84C3 typedef ptrdiff_t GLsizeiptr;
#define GL_TEXTURE4_ARB 0x84C4
#define GL_TEXTURE5_ARB 0x84C5
#define GL_TEXTURE6_ARB 0x84C6
#define GL_TEXTURE7_ARB 0x84C7
#define GL_TEXTURE8_ARB 0x84C8
#define GL_TEXTURE9_ARB 0x84C9
#define GL_TEXTURE10_ARB 0x84CA
#define GL_TEXTURE11_ARB 0x84CB
#define GL_TEXTURE12_ARB 0x84CC
#define GL_TEXTURE13_ARB 0x84CD
#define GL_TEXTURE14_ARB 0x84CE
#define GL_TEXTURE15_ARB 0x84CF
#define GL_TEXTURE16_ARB 0x84D0
#define GL_TEXTURE17_ARB 0x84D1
#define GL_TEXTURE18_ARB 0x84D2
#define GL_TEXTURE19_ARB 0x84D3
#define GL_TEXTURE20_ARB 0x84D4
#define GL_TEXTURE21_ARB 0x84D5
#define GL_TEXTURE22_ARB 0x84D6
#define GL_TEXTURE23_ARB 0x84D7
#define GL_TEXTURE24_ARB 0x84D8
#define GL_TEXTURE25_ARB 0x84D9
#define GL_TEXTURE26_ARB 0x84DA
#define GL_TEXTURE27_ARB 0x84DB
#define GL_TEXTURE28_ARB 0x84DC
#define GL_TEXTURE29_ARB 0x84DD
#define GL_TEXTURE30_ARB 0x84DE
#define GL_TEXTURE31_ARB 0x84DF
#define GL_ACTIVE_TEXTURE_ARB 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
#endif #endif
// GL_EXT_point_parameters #ifndef GL_ARB_vertex_buffer_object
typedef void (APIENTRY *PFNGLPOINTPARAMETERFEXT) (GLenum pname, GLfloat param); // GL types for handling large vertex buffer objects
typedef void (APIENTRY *PFNGLPOINTPARAMETERFVEXT) (GLenum pname, const GLfloat *params); typedef ptrdiff_t GLintptrARB;
typedef ptrdiff_t GLsizeiptrARB;
#ifndef GL_SGIS_point_parameters
#define GL_POINT_SIZE_MIN_EXT 0x8126
#define GL_POINT_SIZE_MIN_SGIS 0x8126
#define GL_POINT_SIZE_MAX_EXT 0x8127
#define GL_POINT_SIZE_MAX_SGIS 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
#define GL_DISTANCE_ATTENUATION_EXT 0x8129
#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
#endif #endif
// GL_EXT_compiled_vertex_array #ifndef GL_ARB_vertex_buffer_object
typedef void (APIENTRY *PFNGLLOCKARRAYSEXT) (GLint first, GLsizei count); #define GL_BUFFER_SIZE_ARB 0x8764
typedef void (APIENTRY *PFNGLUNLOCKARRAYSEXT) (void); #define GL_BUFFER_USAGE_ARB 0x8765
#define GL_ARRAY_BUFFER_ARB 0x8892
#ifndef GL_EXT_compiled_vertex_array #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
#define GL_READ_ONLY_ARB 0x88B8
#define GL_WRITE_ONLY_ARB 0x88B9
#define GL_READ_WRITE_ARB 0x88BA
#define GL_BUFFER_ACCESS_ARB 0x88BB
#define GL_BUFFER_MAPPED_ARB 0x88BC
#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
#define GL_STREAM_DRAW_ARB 0x88E0
#define GL_STREAM_READ_ARB 0x88E1
#define GL_STREAM_COPY_ARB 0x88E2
#define GL_STATIC_DRAW_ARB 0x88E4
#define GL_STATIC_READ_ARB 0x88E5
#define GL_STATIC_COPY_ARB 0x88E6
#define GL_DYNAMIC_DRAW_ARB 0x88E8
#define GL_DYNAMIC_READ_ARB 0x88E9
#define GL_DYNAMIC_COPY_ARB 0x88EA
#endif #endif
// GL_SGIS_texture_edge_clamp // GL_ARB_vertex_buffer_object
#ifndef GL_SGIS_texture_edge_clamp #ifndef GL_ARB_vertex_buffer_object
#define GL_CLAMP_TO_EDGE_SGIS 0x812F #define GL_ARB_vertex_buffer_object 1
typedef void (APIENTRY *GLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRY *GLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
typedef void (APIENTRY *GLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
typedef GLboolean (APIENTRY *GLISBUFFERARBPROC) (GLuint buffer);
typedef void (APIENTRY *GLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
typedef void (APIENTRY *GLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
typedef void (APIENTRY *GLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
typedef GLvoid* (APIENTRY *GLMAPBUFFERARBPROC) (GLenum target, GLenum access);
typedef GLboolean (APIENTRY *GLUNMAPBUFFERARBPROC) (GLenum target);
typedef void (APIENTRY *GLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (APIENTRY *GLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
#endif #endif
// ============================================================================= // =============================================================================
// OpenGL extern declarations // OpenGL extern declarations
#ifdef LC_OPENGL_DYNAMIC
extern PFNGLCLEARINDEX pfnglClearIndex; extern PFNGLCLEARINDEX pfnglClearIndex;
extern PFNGLCLEARCOLOR pfnglClearColor; extern PFNGLCLEARCOLOR pfnglClearColor;
extern PFNGLCLEAR pfnglClear; extern PFNGLCLEAR pfnglClear;
@ -844,48 +808,25 @@ extern PFNGLLOADNAME pfnglLoadName;
extern PFNGLPUSHNAME pfnglPushName; extern PFNGLPUSHNAME pfnglPushName;
extern PFNGLPOPNAME pfnglPopName; extern PFNGLPOPNAME pfnglPopName;
extern PFNGLACTIVETEXTUREARB pfnglActiveTextureARB; #endif // LC_OPENGL_DYNAMIC
extern PFNGLCLIENTACTIVETEXTUREARB pfnglClientActiveTextureARB;
extern PFNGLMULTITEXCOORD1DARB pfnglMultiTexCoord1dARB; extern GLBINDBUFFERARBPROC glBindBufferARB;
extern PFNGLMULTITEXCOORD1DVARB pfnglMultiTexCoord1dvARB; extern GLDELETEBUFFERSARBPROC glDeleteBuffersARB;
extern PFNGLMULTITEXCOORD1FARB pfnglMultiTexCoord1fARB; extern GLGENBUFFERSARBPROC glGenBuffersARB;
extern PFNGLMULTITEXCOORD1FVARB pfnglMultiTexCoord1fvARB; extern GLISBUFFERARBPROC glIsBufferARB;
extern PFNGLMULTITEXCOORD1IARB pfnglMultiTexCoord1iARB; extern GLBUFFERDATAARBPROC glBufferDataARB;
extern PFNGLMULTITEXCOORD1IVARB pfnglMultiTexCoord1ivARB; extern GLBUFFERSUBDATAARBPROC glBufferSubDataARB;
extern PFNGLMULTITEXCOORD1SARB pfnglMultiTexCoord1sARB; extern GLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB;
extern PFNGLMULTITEXCOORD1SVARB pfnglMultiTexCoord1svARB; extern GLMAPBUFFERARBPROC glMapBufferARB;
extern PFNGLMULTITEXCOORD2DARB pfnglMultiTexCoord2dARB; extern GLUNMAPBUFFERARBPROC glUnmapBufferARB;
extern PFNGLMULTITEXCOORD2DVARB pfnglMultiTexCoord2dvARB; extern GLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB;
extern PFNGLMULTITEXCOORD2FARB pfnglMultiTexCoord2fARB; extern GLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
extern PFNGLMULTITEXCOORD2FVARB pfnglMultiTexCoord2fvARB;
extern PFNGLMULTITEXCOORD2IARB pfnglMultiTexCoord2iARB;
extern PFNGLMULTITEXCOORD2IVARB pfnglMultiTexCoord2ivARB;
extern PFNGLMULTITEXCOORD2SARB pfnglMultiTexCoord2sARB;
extern PFNGLMULTITEXCOORD2SVARB pfnglMultiTexCoord2svARB;
extern PFNGLMULTITEXCOORD3DARB pfnglMultiTexCoord3dARB;
extern PFNGLMULTITEXCOORD3DVARB pfnglMultiTexCoord3dvARB;
extern PFNGLMULTITEXCOORD3FARB pfnglMultiTexCoord3fARB;
extern PFNGLMULTITEXCOORD3FVARB pfnglMultiTexCoord3fvARB;
extern PFNGLMULTITEXCOORD3IARB pfnglMultiTexCoord3iARB;
extern PFNGLMULTITEXCOORD3IVARB pfnglMultiTexCoord3ivARB;
extern PFNGLMULTITEXCOORD3SARB pfnglMultiTexCoord3sARB;
extern PFNGLMULTITEXCOORD3SVARB pfnglMultiTexCoord3svARB;
extern PFNGLMULTITEXCOORD4DARB pfnglMultiTexCoord4dARB;
extern PFNGLMULTITEXCOORD4DVARB pfnglMultiTexCoord4dvARB;
extern PFNGLMULTITEXCOORD4FARB pfnglMultiTexCoord4fARB;
extern PFNGLMULTITEXCOORD4FVARB pfnglMultiTexCoord4fvARB;
extern PFNGLMULTITEXCOORD4IARB pfnglMultiTexCoord4iARB;
extern PFNGLMULTITEXCOORD4IVARB pfnglMultiTexCoord4ivARB;
extern PFNGLMULTITEXCOORD4SARB pfnglMultiTexCoord4sARB;
extern PFNGLMULTITEXCOORD4SVARB pfnglMultiTexCoord4svARB;
extern PFNGLPOINTPARAMETERFEXT pfnglPointParameterfEXT;
extern PFNGLPOINTPARAMETERFVEXT pfnglPointParameterfvEXT;
extern PFNGLLOCKARRAYSEXT pfnglLockArraysEXT;
extern PFNGLUNLOCKARRAYSEXT pfnglUnlockArraysEXT;
// ============================================================================= // =============================================================================
// Replace OpenGL function names with the dynamic functions // Replace OpenGL function names with the dynamic functions
#ifdef LC_OPENGL_DYNAMIC
#define glClearIndex pfnglClearIndex #define glClearIndex pfnglClearIndex
#define glClearColor pfnglClearColor #define glClearColor pfnglClearColor
#define glClear pfnglClear #define glClear pfnglClear
@ -1223,43 +1164,6 @@ extern PFNGLUNLOCKARRAYSEXT pfnglUnlockArraysEXT;
#define glPushName pfnglPushName #define glPushName pfnglPushName
#define glPopName pfnglPopName #define glPopName pfnglPopName
#define glActiveTextureARB pfnglActiveTextureARB #endif // LC_OPENGL_DYNAMIC
#define glClientActiveTextureARB pfnglClientActiveTextureARB
#define glMultiTexCoord1dARB pfnglMultiTexCoord1dARB
#define glMultiTexCoord1dvARB pfnglMultiTexCoord1dvARB
#define glMultiTexCoord1fARB pfnglMultiTexCoord1fARB
#define glMultiTexCoord1fvARB pfnglMultiTexCoord1fvARB
#define glMultiTexCoord1iARB pfnglMultiTexCoord1iARB
#define glMultiTexCoord1ivARB pfnglMultiTexCoord1ivARB
#define glMultiTexCoord1sARB pfnglMultiTexCoord1sARB
#define glMultiTexCoord1svARB pfnglMultiTexCoord1svARB
#define glMultiTexCoord2dARB pfnglMultiTexCoord2dARB
#define glMultiTexCoord2dvARB pfnglMultiTexCoord2dvARB
#define glMultiTexCoord2fARB pfnglMultiTexCoord2fARB
#define glMultiTexCoord2fvARB pfnglMultiTexCoord2fvARB
#define glMultiTexCoord2iARB pfnglMultiTexCoord2iARB
#define glMultiTexCoord2ivARB pfnglMultiTexCoord2ivARB
#define glMultiTexCoord2sARB pfnglMultiTexCoord2sARB
#define glMultiTexCoord2svARB pfnglMultiTexCoord2svARB
#define glMultiTexCoord3dARB pfnglMultiTexCoord3dARB
#define glMultiTexCoord3dvARB pfnglMultiTexCoord3dvARB
#define glMultiTexCoord3fARB pfnglMultiTexCoord3fARB
#define glMultiTexCoord3fvARB pfnglMultiTexCoord3fvARB
#define glMultiTexCoord3iARB pfnglMultiTexCoord3iARB
#define glMultiTexCoord3ivARB pfnglMultiTexCoord3ivARB
#define glMultiTexCoord3sARB pfnglMultiTexCoord3sARB
#define glMultiTexCoord3svARB pfnglMultiTexCoord3svARB
#define glMultiTexCoord4dARB pfnglMultiTexCoord4dARB
#define glMultiTexCoord4dvARB pfnglMultiTexCoord4dvARB
#define glMultiTexCoord4fARB pfnglMultiTexCoord4fARB
#define glMultiTexCoord4fvARB pfnglMultiTexCoord4fvARB
#define glMultiTexCoord4iARB pfnglMultiTexCoord4iARB
#define glMultiTexCoord4ivARB pfnglMultiTexCoord4ivARB
#define glMultiTexCoord4sARB pfnglMultiTexCoord4sARB
#define glMultiTexCoord4svARB pfnglMultiTexCoord4svARB
#define glPointParameterfEXT pfnglPointParameterfEXT
#define glPointParameterfvEXT pfnglPointParameterfvEXT
#define glLockArraysEXT pfnglLockArraysEXT
#define glUnlockArraysEXT pfnglUnlockArraysEXT
#endif // _OPENGL_H_ #endif // _OPENGL_H_

View file

@ -56,19 +56,9 @@ inline static void SetCurrentColor(unsigned char nColor, bool bLighting)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Piece construction/destruction // Piece construction/destruction
static bool lockarrays = false;
Piece::Piece(PieceInfo* pPieceInfo) Piece::Piece(PieceInfo* pPieceInfo)
: Object (LC_OBJECT_PIECE) : Object (LC_OBJECT_PIECE)
{ {
static bool first_time = true;
if (first_time)
{
first_time = false;
lockarrays = GL_HasCompiledVertexArrays ();
}
m_pNext = NULL; m_pNext = NULL;
m_pPieceInfo = pPieceInfo; m_pPieceInfo = pPieceInfo;
m_nState = 0; m_nState = 0;
@ -1207,17 +1197,12 @@ void Piece::Render(bool bLighting, bool bEdges)
while (colors--) while (colors--)
{ {
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
if (*info == LC_COL_DEFAULT) if (*info == LC_COL_DEFAULT)
SetCurrentColor(mColorIndex, bLighting); SetCurrentColor(mColorIndex, bLighting);
else else
SetCurrentColor((unsigned char)*info, bLighting); SetCurrentColor((unsigned char)*info, bLighting);
info++; info++;
if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
if (*info) if (*info)
{ {
glDrawElements(GL_QUADS, *info, GL_UNSIGNED_INT, info+1); glDrawElements(GL_QUADS, *info, GL_UNSIGNED_INT, info+1);
@ -1238,17 +1223,11 @@ void Piece::Render(bool bLighting, bool bEdges)
{ {
if (m_nState & LC_PIECE_SELECTED) if (m_nState & LC_PIECE_SELECTED)
{ {
if (lock)
glUnlockArraysEXT();
if (m_nState & LC_PIECE_FOCUSED) if (m_nState & LC_PIECE_FOCUSED)
lcSetColorFocused(); lcSetColorFocused();
else else
lcSetColorSelected(); lcSetColorSelected();
if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1);
} }
else else
@ -1259,9 +1238,6 @@ void Piece::Render(bool bLighting, bool bEdges)
} }
else else
info++; info++;
if (lock)
glUnlockArraysEXT();
} }
} }
else else
@ -1272,17 +1248,12 @@ void Piece::Render(bool bLighting, bool bEdges)
while (colors--) while (colors--)
{ {
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
if (*info == LC_COL_DEFAULT) if (*info == LC_COL_DEFAULT)
SetCurrentColor(mColorIndex, bLighting); SetCurrentColor(mColorIndex, bLighting);
else else
SetCurrentColor((unsigned char)*info, bLighting); SetCurrentColor((unsigned char)*info, bLighting);
info++; info++;
if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
if (*info) if (*info)
{ {
glDrawElements(GL_QUADS, *info, GL_UNSIGNED_SHORT, info+1); glDrawElements(GL_QUADS, *info, GL_UNSIGNED_SHORT, info+1);
@ -1303,16 +1274,11 @@ void Piece::Render(bool bLighting, bool bEdges)
{ {
if (m_nState & LC_PIECE_SELECTED) if (m_nState & LC_PIECE_SELECTED)
{ {
if (lock)
glUnlockArraysEXT();
if (m_nState & LC_PIECE_FOCUSED) if (m_nState & LC_PIECE_FOCUSED)
lcSetColorFocused(); lcSetColorFocused();
else else
lcSetColorSelected(); lcSetColorSelected();
if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1);
} }
else else
@ -1323,9 +1289,6 @@ void Piece::Render(bool bLighting, bool bEdges)
} }
else else
info++; info++;
if (lock)
glUnlockArraysEXT();
} }
} }

View file

@ -180,15 +180,15 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame)
1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI, 1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
int pixelformat = OpenGLChoosePixelFormat(pMemDC->m_hDC, &pfd); int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd);
OpenGLDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
OpenGLSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
// Creating a OpenGL context // Creating a OpenGL context
HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc()); HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc());
// Setting up the current OpenGL context // Setting up the current OpenGL context
pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
double aspect = (float)w/(float)h; double aspect = (float)w/(float)h;
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
@ -373,8 +373,8 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame)
free(previous); free(previous);
} }
pfnwglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
pfnwglDeleteContext(hmemrc); wglDeleteContext(hmemrc);
SelectObject(pMemDC->GetSafeHdc(), hBmOld); SelectObject(pMemDC->GetSafeHdc(), hBmOld);
DeleteObject(hBm); DeleteObject(hBm);
delete pMemDC; delete pMemDC;
@ -566,11 +566,11 @@ static void PrintPiecesThread(void* pv)
PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI, PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
int pixelformat = OpenGLChoosePixelFormat(pMemDC->m_hDC, &pfd); int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd);
OpenGLDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
OpenGLSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc()); HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc());
pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
double aspect = (float)picw/(float)h; double aspect = (float)picw/(float)h;
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, picw, h); glViewport(0, 0, picw, h);
@ -773,8 +773,8 @@ static void PrintPiecesThread(void* pv)
free(previous); free(previous);
} }
pfnwglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
pfnwglDeleteContext(hmemrc); wglDeleteContext(hmemrc);
SelectObject(pMemDC->GetSafeHdc(), hBmOld); SelectObject(pMemDC->GetSafeHdc(), hBmOld);
DeleteObject(hBm); DeleteObject(hBm);
delete pMemDC; delete pMemDC;

View file

@ -31,7 +31,7 @@
#include <afxcontrolbars.h> // MFC support for ribbons and control bars #include <afxcontrolbars.h> // MFC support for ribbons and control bars
#include "opengl.h" #include <GL/gl.h>
#define IDT_LC_SAVETIMER (WM_USER+200) #define IDT_LC_SAVETIMER (WM_USER+200)
#define IDT_LC_WHEELTIMER (WM_USER+201) #define IDT_LC_WHEELTIMER (WM_USER+201)

View file

@ -1373,7 +1373,7 @@ bool SystemDoDialog(int nMode, void* param)
case LC_DLG_ABOUT: case LC_DLG_ABOUT:
{ {
CAboutDlg dlg; CAboutDlg dlg;
dlg.m_hViewDC = pfnwglGetCurrentDC(); dlg.m_hViewDC = wglGetCurrentDC();
dlg.DoModal(); dlg.DoModal();
} break; } break;
} }
@ -1400,8 +1400,8 @@ void* Sys_StartMemoryRender(int width, int height)
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
CView* pView = pFrame->GetActiveView(); CView* pView = pFrame->GetActiveView();
CDC* pDC = pView->GetDC(); CDC* pDC = pView->GetDC();
render->oldhdc = pfnwglGetCurrentDC(); render->oldhdc = wglGetCurrentDC();
render->oldhrc = pfnwglGetCurrentContext(); render->oldhrc = wglGetCurrentContext();
render->hdc = CreateCompatibleDC(pDC->m_hDC); render->hdc = CreateCompatibleDC(pDC->m_hDC);
// Preparing bitmap header for DIB section // Preparing bitmap header for DIB section
@ -1427,11 +1427,11 @@ void* Sys_StartMemoryRender(int width, int height)
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
int pixelformat = OpenGLChoosePixelFormat(render->hdc, &pfd); int pixelformat = ChoosePixelFormat(render->hdc, &pfd);
OpenGLDescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
OpenGLSetPixelFormat(render->hdc, pixelformat, &pfd); SetPixelFormat(render->hdc, pixelformat, &pfd);
render->hrc = pfnwglCreateContext(render->hdc); render->hrc = wglCreateContext(render->hdc);
pfnwglMakeCurrent(render->hdc, render->hrc); wglMakeCurrent(render->hdc, render->hrc);
return render; return render;
} }
@ -1440,8 +1440,8 @@ void Sys_FinishMemoryRender(void* param)
{ {
LC_RENDER* render = (LC_RENDER*)param; LC_RENDER* render = (LC_RENDER*)param;
pfnwglMakeCurrent (render->oldhdc, render->oldhrc); wglMakeCurrent (render->oldhdc, render->oldhrc);
pfnwglDeleteContext(render->hrc); wglDeleteContext(render->hrc);
SelectObject(render->hdc, render->oldhbm); SelectObject(render->hdc, render->oldhbm);
DeleteObject(render->hbm); DeleteObject(render->hbm);
DeleteDC(render->hdc); DeleteDC(render->hdc);

View file

@ -59,8 +59,8 @@ void CTerrainWnd::OnPaint()
{ {
CPaintDC dc(this); // device context for painting CPaintDC dc(this); // device context for painting
HDC oldDC = pfnwglGetCurrentDC(); HDC oldDC = wglGetCurrentDC();
HGLRC oldRC = pfnwglGetCurrentContext(); HGLRC oldRC = wglGetCurrentContext();
if (m_pPalette) if (m_pPalette)
{ {
@ -68,7 +68,7 @@ void CTerrainWnd::OnPaint()
m_pDC->RealizePalette(); m_pDC->RealizePalette();
} }
pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC); wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -79,9 +79,8 @@ void CTerrainWnd::OnPaint()
m_pTerrain->Render(m_pCamera, aspect); m_pTerrain->Render(m_pCamera, aspect);
glFlush(); SwapBuffers(dc.m_hDC);
OpenGLSwapBuffers (dc.m_hDC); wglMakeCurrent(oldDC, oldRC);
pfnwglMakeCurrent (oldDC, oldRC);
} }
void CTerrainWnd::OnSize(UINT nType, int cx, int cy) void CTerrainWnd::OnSize(UINT nType, int cx, int cy)
@ -105,7 +104,7 @@ void CTerrainWnd::OnDestroy()
} }
if (m_hglRC) if (m_hglRC)
pfnwglDeleteContext(m_hglRC); wglDeleteContext(m_hglRC);
if (m_pDC) if (m_pDC)
delete m_pDC; delete m_pDC;
@ -132,11 +131,11 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
pfd.cDepthBits = 32; pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE; pfd.iLayerType = PFD_MAIN_PLANE;
int nPixelFormat = OpenGLChoosePixelFormat(m_pDC->m_hDC, &pfd); int nPixelFormat = ChoosePixelFormat(m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0) if (nPixelFormat == 0)
return -1; return -1;
if (!OpenGLSetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd)) if (!SetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
return -1; return -1;
m_pPalette = new CPalette; m_pPalette = new CPalette;
@ -152,13 +151,13 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
} }
// Create a rendering context. // Create a rendering context.
m_hglRC = pfnwglCreateContext(m_pDC->m_hDC); m_hglRC = wglCreateContext(m_pDC->m_hDC);
if (!m_hglRC) if (!m_hglRC)
return -1; return -1;
HDC oldDC = pfnwglGetCurrentDC(); HDC oldDC = wglGetCurrentDC();
HGLRC oldRC = pfnwglGetCurrentContext(); HGLRC oldRC = wglGetCurrentContext();
pfnwglMakeCurrent (m_pDC->m_hDC, m_hglRC); wglMakeCurrent (m_pDC->m_hDC, m_hglRC);
// Initialize OpenGL the way we want it. // Initialize OpenGL the way we want it.
float ambient [] = {0.0f, 0.0f, 0.0f, 1.0f}; float ambient [] = {0.0f, 0.0f, 0.0f, 1.0f};
@ -180,19 +179,19 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
pfnwglMakeCurrent(oldDC, oldRC); wglMakeCurrent(oldDC, oldRC);
return 0; return 0;
} }
void CTerrainWnd::LoadTexture(bool linear) void CTerrainWnd::LoadTexture(bool linear)
{ {
HDC oldDC = pfnwglGetCurrentDC(); HDC oldDC = wglGetCurrentDC();
HGLRC oldRC = pfnwglGetCurrentContext(); HGLRC oldRC = wglGetCurrentContext();
pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC); wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
m_pTerrain->LoadTexture(linear); m_pTerrain->LoadTexture(linear);
pfnwglMakeCurrent(oldDC, oldRC); wglMakeCurrent(oldDC, oldRC);
} }
void CTerrainWnd::OnLButtonDown(UINT nFlags, CPoint point) void CTerrainWnd::OnLButtonDown(UINT nFlags, CPoint point)

View file

@ -128,8 +128,8 @@ BOOL CreateRGBPalette(HDC hDC, CPalette **ppCPalette)
LOGPALETTE *pPal; LOGPALETTE *pPal;
WORD n, i; WORD n, i;
n = OpenGLGetPixelFormat(hDC); n = GetPixelFormat(hDC);
OpenGLDescribePixelFormat(hDC, n, sizeof(pfd), &pfd); DescribePixelFormat(hDC, n, sizeof(pfd), &pfd);
if (!(pfd.dwFlags & PFD_NEED_PALETTE)) return FALSE; if (!(pfd.dwFlags & PFD_NEED_PALETTE)) return FALSE;

View file

@ -47,7 +47,7 @@ BOOL CAboutDlg::OnInitDialog()
// Initialize the OpenGL information box. // Initialize the OpenGL information box.
CString info, tmp; CString info, tmp;
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
OpenGLDescribePixelFormat(m_hViewDC, OpenGLGetPixelFormat(m_hViewDC), sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(m_hViewDC, GetPixelFormat(m_hViewDC), sizeof(PIXELFORMATDESCRIPTOR), &pfd);
info = ("Pixel Format: "); info = ("Pixel Format: ");
if (pfd.iPixelType == PFD_TYPE_RGBA) if (pfd.iPixelType == PFD_TYPE_RGBA)

View file

@ -1,4 +1,5 @@
#include "lc_global.h" #include "lc_global.h"
#include "opengl.h"
#include "glwindow.h" #include "glwindow.h"
#include "tools.h" #include "tools.h"
@ -168,11 +169,11 @@ bool GLWindow::CreateFromWindow(void* data)
pfd.cDepthBits = 24; pfd.cDepthBits = 24;
pfd.iLayerType = PFD_MAIN_PLANE; pfd.iLayerType = PFD_MAIN_PLANE;
int nPixelFormat = OpenGLChoosePixelFormat(prv->m_pDC->m_hDC, &pfd); int nPixelFormat = ChoosePixelFormat(prv->m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0) if (nPixelFormat == 0)
return false; return false;
if (!OpenGLSetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) if (!SetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd))
return false; return false;
prv->m_pPal = new CPalette; prv->m_pPal = new CPalette;
@ -189,14 +190,14 @@ bool GLWindow::CreateFromWindow(void* data)
} }
// Create a rendering context. // Create a rendering context.
prv->m_hrc = pfnwglCreateContext(prv->m_pDC->m_hDC); prv->m_hrc = wglCreateContext(prv->m_pDC->m_hDC);
if (!prv->m_hrc) if (!prv->m_hrc)
return false; return false;
if (m_pShare) if (m_pShare)
{ {
GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData; GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData;
pfnwglShareLists(share->m_hrc, prv->m_hrc); wglShareLists(share->m_hrc, prv->m_hrc);
} }
return true; return true;
@ -222,11 +223,11 @@ bool GLWindow::CreateFromBitmap(void* Data)
pfd.cDepthBits = 16; pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE; pfd.iLayerType = PFD_MAIN_PLANE;
int nPixelFormat = OpenGLChoosePixelFormat(prv->m_pDC->m_hDC, &pfd); int nPixelFormat = ChoosePixelFormat(prv->m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0) if (nPixelFormat == 0)
return false; return false;
if (!OpenGLSetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) if (!SetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd))
return false; return false;
prv->m_pPal = new CPalette; prv->m_pPal = new CPalette;
@ -243,14 +244,14 @@ bool GLWindow::CreateFromBitmap(void* Data)
} }
// Create a rendering context. // Create a rendering context.
prv->m_hrc = pfnwglCreateContext(prv->m_pDC->m_hDC); prv->m_hrc = wglCreateContext(prv->m_pDC->m_hDC);
if (!prv->m_hrc) if (!prv->m_hrc)
return false; return false;
if (m_pShare) if (m_pShare)
{ {
GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData; GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData;
pfnwglShareLists(share->m_hrc, prv->m_hrc); wglShareLists(share->m_hrc, prv->m_hrc);
} }
return true; return true;
@ -270,7 +271,7 @@ void GLWindow::DestroyContext()
} }
if (prv->m_hrc) if (prv->m_hrc)
pfnwglDeleteContext(prv->m_hrc); wglDeleteContext(prv->m_hrc);
prv->m_hrc = NULL; prv->m_hrc = NULL;
if (prv->m_pDC) if (prv->m_pDC)
@ -294,14 +295,14 @@ bool GLWindow::MakeCurrent()
prv->m_pDC->RealizePalette(); prv->m_pDC->RealizePalette();
} }
return (pfnwglMakeCurrent(prv->m_pDC->m_hDC, prv->m_hrc) != 0); return (wglMakeCurrent(prv->m_pDC->m_hDC, prv->m_hrc) != 0);
} }
void GLWindow::SwapBuffers() void GLWindow::SwapBuffers()
{ {
GLWindowPrivate *prv = (GLWindowPrivate*)m_pData; GLWindowPrivate *prv = (GLWindowPrivate*)m_pData;
OpenGLSwapBuffers(prv->m_pDC->m_hDC); ::SwapBuffers(prv->m_pDC->m_hDC);
} }
void GLWindow::Redraw(bool ForceRedraw) void GLWindow::Redraw(bool ForceRedraw)

View file

@ -55,7 +55,7 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wininet.lib;vfw32.lib</AdditionalDependencies> <AdditionalDependencies>wininet.lib;vfw32.lib;opengl32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>jpeglib\debug;libpng\debug;zlib\debug;3dsftk\debug</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>jpeglib\debug;libpng\debug;zlib\debug;3dsftk\debug</AdditionalLibraryDirectories>
</Link> </Link>
<Midl> <Midl>
@ -85,7 +85,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wininet.lib;vfw32.lib</AdditionalDependencies> <AdditionalDependencies>wininet.lib;vfw32.lib;opengl32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>jpeglib\release;libpng\release;zlib\release;3dsftk\release</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>jpeglib\release;libpng\release;zlib\release;3dsftk\release</AdditionalLibraryDirectories>
<GenerateMapFile>true</GenerateMapFile> <GenerateMapFile>true</GenerateMapFile>
</Link> </Link>

View file

@ -1,173 +1,41 @@
#include "lc_global.h" #include "lc_global.h"
#include "opengl.h" #include "opengl.h"
static HMODULE gl_module;
static bool gl_ignore_GDI = false;
// ============================================================================
// Function pointers
static WGLCHOOSEPIXELFORMAT pfnwglChoosePixelFormat;
static WGLDESCRIBEPIXELFORMAT pfnwglDescribePixelFormat;
static WGLGETPIXELFORMAT pfnwglGetPixelFormat;
static WGLSETPIXELFORMAT pfnwglSetPixelFormat;
static WGLSWAPBUFFERS pfnwglSwapBuffers;
WGLCOPYCONTEXT pfnwglCopyContext;
WGLCREATECONTEXT pfnwglCreateContext;
WGLCREATELAYERCONTEXT pfnwglCreateLayerContext;
WGLDELETECONTEXT pfnwglDeleteContext;
WGLGETCURRENTCONTEXT pfnwglGetCurrentContext;
WGLGETCURRENTDC pfnwglGetCurrentDC;
WGLGETPROCADDRESS pfnwglGetProcAddress;
WGLMAKECURRENT pfnwglMakeCurrent;
WGLSHARELISTS pfnwglShareLists;
WGLUSEFONTBITMAPS pfnwglUseFontBitmaps;
WGLUSEFONTOUTLINES pfnwglUseFontOutlines;
WGLDESCRIBELAYERPLANE pfnwglDescribeLayerPlane;
WGLSETLAYERPALETTEENTRIES pfnwglSetLayerPaletteEntries;
WGLGETLAYERPALETTEENTRIES pfnwglGetLayerPaletteEntries;
WGLREALIZELAYERPALETTE pfnwglRealizeLayerPalette;
WGLSWAPLAYERBUFFERS pfnwglSwapLayerBuffers;
WGLSWAPINTERVALEXT pfnwglSwapIntervalEXT;
WGLGETDEVICEGAMMARAMPEXT pfnwglGetDeviceGammaRampEXT;
WGLSETDEVICEGAMMARAMPEXT pfnwglSetDeviceGammaRampEXT;
// ============================================================================
// Global functions
BOOL OpenGLSwapBuffers(HDC hdc) BOOL OpenGLSwapBuffers(HDC hdc)
{ {
if (!gl_ignore_GDI)
return SwapBuffers(hdc); return SwapBuffers(hdc);
else
return pfnwglSwapBuffers (hdc);
} }
int OpenGLChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd) int OpenGLChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd)
{ {
if (!gl_ignore_GDI)
return ChoosePixelFormat(hdc, ppfd); return ChoosePixelFormat(hdc, ppfd);
else
return pfnwglChoosePixelFormat (hdc, ppfd);
} }
int OpenGLDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) int OpenGLDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
{ {
if (!gl_ignore_GDI)
return DescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd); return DescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
else
return pfnwglDescribePixelFormat (hdc, iPixelFormat, nBytes, ppfd);
} }
BOOL OpenGLSetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd) BOOL OpenGLSetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd)
{ {
if (!gl_ignore_GDI)
return SetPixelFormat(hdc, iPixelFormat, ppfd); return SetPixelFormat(hdc, iPixelFormat, ppfd);
else
return pfnwglSetPixelFormat (hdc, iPixelFormat, ppfd);
} }
int OpenGLGetPixelFormat(HDC hdc) int OpenGLGetPixelFormat(HDC hdc)
{ {
if (!gl_ignore_GDI)
return GetPixelFormat(hdc); return GetPixelFormat(hdc);
else
return pfnwglGetPixelFormat (hdc);
} }
void* Sys_GLGetProc (const char *symbol) void* Sys_GLGetExtension(const char* Symbol)
{ {
return GetProcAddress (gl_module, symbol); return wglGetProcAddress(Symbol);
}
void* Sys_GLGetExtension (const char *symbol)
{
return pfnwglGetProcAddress (symbol);
} }
bool Sys_GLOpenLibrary(const char* libname) bool Sys_GLOpenLibrary(const char* libname)
{ {
if (libname)
{
gl_module = LoadLibrary (libname);
if (strcmp(libname, "opengl32.dll"))
gl_ignore_GDI = true;
}
if (gl_module == NULL)
{
gl_module = LoadLibrary ("opengl32.dll");
gl_ignore_GDI = false;
}
if (gl_module == NULL)
{
gl_module = LoadLibrary ("opengl.dll");
gl_ignore_GDI = true;
}
if (gl_module == NULL)
return false;
pfnwglChoosePixelFormat = (WGLCHOOSEPIXELFORMAT) Sys_GLGetProc ("wglChoosePixelFormat");
pfnwglDescribePixelFormat = (WGLDESCRIBEPIXELFORMAT) Sys_GLGetProc ("wglDescribePixelFormat");
pfnwglGetPixelFormat = (WGLGETPIXELFORMAT) Sys_GLGetProc ("wglGetPixelFormat");
pfnwglSetPixelFormat = (WGLSETPIXELFORMAT) Sys_GLGetProc ("wglSetPixelFormat");
pfnwglSwapBuffers = (WGLSWAPBUFFERS) Sys_GLGetProc ("wglSwapBuffers");
pfnwglCopyContext = (WGLCOPYCONTEXT) Sys_GLGetProc ("wglCopyContext");
pfnwglCreateContext = (WGLCREATECONTEXT) Sys_GLGetProc ("wglCreateContext");
pfnwglCreateLayerContext = (WGLCREATELAYERCONTEXT) Sys_GLGetProc ("wglCreateLayerContext");
pfnwglDeleteContext = (WGLDELETECONTEXT) Sys_GLGetProc ("wglDeleteContext");
pfnwglGetCurrentContext = (WGLGETCURRENTCONTEXT) Sys_GLGetProc ("wglGetCurrentContext");
pfnwglGetCurrentDC = (WGLGETCURRENTDC) Sys_GLGetProc ("wglGetCurrentDC");
pfnwglGetProcAddress = (WGLGETPROCADDRESS) Sys_GLGetProc ("wglGetProcAddress");
pfnwglMakeCurrent = (WGLMAKECURRENT) Sys_GLGetProc ("wglMakeCurrent");
pfnwglShareLists = (WGLSHARELISTS) Sys_GLGetProc ("wglShareLists");
pfnwglUseFontBitmaps = (WGLUSEFONTBITMAPS) Sys_GLGetProc ("wglUseFontBitmaps");
pfnwglUseFontOutlines = (WGLUSEFONTOUTLINES) Sys_GLGetProc ("wglUseFontOutlines");
pfnwglDescribeLayerPlane = (WGLDESCRIBELAYERPLANE) Sys_GLGetProc ("wglDescribeLayerPlane");
pfnwglSetLayerPaletteEntries = (WGLSETLAYERPALETTEENTRIES) Sys_GLGetProc ("wglSetLayerPaletteEntries");
pfnwglGetLayerPaletteEntries = (WGLGETLAYERPALETTEENTRIES) Sys_GLGetProc ("wglGetLayerPaletteEntries");
pfnwglRealizeLayerPalette = (WGLREALIZELAYERPALETTE) Sys_GLGetProc ("wglRealizeLayerPalette");
pfnwglSwapLayerBuffers = (WGLSWAPLAYERBUFFERS) Sys_GLGetProc ("wglSwapLayerBuffers");
pfnwglSwapIntervalEXT = (WGLSWAPINTERVALEXT) Sys_GLGetProc ("wglSwapIntervalEXT");
pfnwglGetDeviceGammaRampEXT = (WGLGETDEVICEGAMMARAMPEXT) Sys_GLGetProc ("wglGetDeviceGammaRampEXT");
pfnwglSetDeviceGammaRampEXT = (WGLSETDEVICEGAMMARAMPEXT) Sys_GLGetProc ("wglSetDeviceGammaRampEXT");
return true; return true;
} }
void Sys_GLCloseLibrary() void Sys_GLCloseLibrary()
{ {
if (gl_module)
{
FreeLibrary (gl_module);
gl_module = NULL;
}
pfnwglChoosePixelFormat = NULL;
pfnwglDescribePixelFormat = NULL;
pfnwglGetPixelFormat = NULL;
pfnwglSetPixelFormat = NULL;
pfnwglSwapBuffers = NULL;
pfnwglCopyContext = NULL;
pfnwglCreateContext = NULL;
pfnwglCreateLayerContext = NULL;
pfnwglDeleteContext = NULL;
pfnwglGetCurrentContext = NULL;
pfnwglGetCurrentDC = NULL;
pfnwglGetProcAddress = NULL;
pfnwglMakeCurrent = NULL;
pfnwglShareLists = NULL;
pfnwglUseFontBitmaps = NULL;
pfnwglUseFontOutlines = NULL;
pfnwglDescribeLayerPlane = NULL;
pfnwglSetLayerPaletteEntries = NULL;
pfnwglGetLayerPaletteEntries = NULL;
pfnwglRealizeLayerPalette = NULL;
pfnwglSwapLayerBuffers = NULL;
pfnwglSwapIntervalEXT = NULL;
pfnwglGetDeviceGammaRampEXT = NULL;
pfnwglSetDeviceGammaRampEXT = NULL;
} }

View file

@ -1,101 +0,0 @@
#ifndef _WIN_GL_H_
#define _WIN_GL_H_
// ============================================================================
// WGL functions typedefs
// these functions depend on the driver loaded
BOOL OpenGLSwapBuffers (HDC hdc);
int OpenGLChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd);
int OpenGLDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd);
BOOL OpenGLSetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd);
int OpenGLGetPixelFormat(HDC hdc);
typedef int (WINAPI* WGLCHOOSEPIXELFORMAT) (HDC, CONST PIXELFORMATDESCRIPTOR *);
typedef int (WINAPI* WGLDESCRIBEPIXELFORMAT) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
typedef int (WINAPI* WGLGETPIXELFORMAT)(HDC);
typedef BOOL (WINAPI* WGLSETPIXELFORMAT)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
typedef BOOL (WINAPI* WGLSWAPBUFFERS)(HDC);
typedef BOOL (WINAPI* WGLCOPYCONTEXT)(HGLRC, HGLRC, UINT);
typedef HGLRC (WINAPI* WGLCREATECONTEXT)(HDC);
typedef HGLRC (WINAPI* WGLCREATELAYERCONTEXT)(HDC, int);
typedef BOOL (WINAPI* WGLDELETECONTEXT)(HGLRC);
typedef HGLRC (WINAPI* WGLGETCURRENTCONTEXT)(VOID);
typedef HDC (WINAPI* WGLGETCURRENTDC)(VOID);
typedef PROC (WINAPI* WGLGETPROCADDRESS)(LPCSTR);
typedef BOOL (WINAPI* WGLMAKECURRENT)(HDC, HGLRC);
typedef BOOL (WINAPI* WGLSHARELISTS)(HGLRC, HGLRC);
typedef BOOL (WINAPI* WGLUSEFONTBITMAPS)(HDC, DWORD, DWORD, DWORD);
typedef BOOL (WINAPI* WGLUSEFONTOUTLINES)(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);
typedef BOOL (WINAPI* WGLDESCRIBELAYERPLANE)(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR);
typedef int (WINAPI* WGLSETLAYERPALETTEENTRIES)(HDC, int, int, int, CONST COLORREF *);
typedef int (WINAPI* WGLGETLAYERPALETTEENTRIES)(HDC, int, int, int, COLORREF *);
typedef BOOL (WINAPI* WGLREALIZELAYERPALETTE)(HDC, int, BOOL);
typedef BOOL (WINAPI* WGLSWAPLAYERBUFFERS)(HDC, UINT);
typedef BOOL (WINAPI* WGLSWAPINTERVALEXT)(int interval);
typedef BOOL (WINAPI* WGLGETDEVICEGAMMARAMPEXT) (unsigned char *pRed, unsigned char *pGreen, unsigned char *pBlue);
typedef BOOL (WINAPI* WGLSETDEVICEGAMMARAMPEXT) (const unsigned char *pRed, const unsigned char *pGreen, const unsigned char *pBlue);
// ============================================================================
// WGL extern declarations
//extern WGLCHOOSEPIXELFORMAT pfnwglChoosePixelFormat;
//extern WGLDESCRIBEPIXELFORMAT pfnwglDescribePixelFormat;
//extern WGLGETPIXELFORMAT pfnwglGetPixelFormat;
//extern WGLSETPIXELFORMAT pfnwglSetPixelFormat;
//extern WGLSWAPBUFFERS pfnwglSwapBuffers;
extern WGLCOPYCONTEXT pfnwglCopyContext;
extern WGLCREATECONTEXT pfnwglCreateContext;
extern WGLCREATELAYERCONTEXT pfnwglCreateLayerContext;
extern WGLDELETECONTEXT pfnwglDeleteContext;
extern WGLGETCURRENTCONTEXT pfnwglGetCurrentContext;
extern WGLGETCURRENTDC pfnwglGetCurrentDC;
extern WGLGETPROCADDRESS pfnwglGetProcAddress;
extern WGLMAKECURRENT pfnwglMakeCurrent;
extern WGLSHARELISTS pfnwglShareLists;
extern WGLUSEFONTBITMAPS pfnwglUseFontBitmaps;
extern WGLUSEFONTOUTLINES pfnwglUseFontOutlines;
extern WGLDESCRIBELAYERPLANE pfnwglDescribeLayerPlane;
extern WGLSETLAYERPALETTEENTRIES pfnwglSetLayerPaletteEntries;
extern WGLGETLAYERPALETTEENTRIES pfnwglGetLayerPaletteEntries;
extern WGLREALIZELAYERPALETTE pfnwglRealizeLayerPalette;
extern WGLSWAPLAYERBUFFERS pfnwglSwapLayerBuffers;
extern WGLSWAPINTERVALEXT pfnwglSwapIntervalEXT;
extern WGLGETDEVICEGAMMARAMPEXT pfnwglGetDeviceGammaRampEXT;
extern WGLSETDEVICEGAMMARAMPEXT pfnwglSetDeviceGammaRampEXT;
// ============================================================================
// Replace WGL functions
/*
#undef wglUseFontBitmaps
#undef wglUseFontOutlines
//#define wglChoosePixelFormat pfnwglChoosePixelFormat;
//#define wglDescribePixelFormat pfnwglDescribePixelFormat;
//#define wglGetPixelFormat pfnwglGetPixelFormat;
//#define wglSetPixelFormat pfnwglSetPixelFormat;
//#define wglSwapBuffers pfnwglSwapBuffers;
#define wglCopyContext pfnwglCopyContext;
#define wglCreateContext pfnwglCreateContext;
#define wglCreateLayerContext pfnwglCreateLayerContext;
#define wglDeleteContext pfnwglDeleteContext;
#define wglGetCurrentContext pfnwglGetCurrentContext;
#define wglGetCurrentDC pfnwglGetCurrentDC;
#define wglGetProcAddress pfnwglGetProcAddress;
#define wglMakeCurrent pfnwglMakeCurrent;
#define wglShareLists pfnwglShareLists;
#define wglUseFontBitmaps pfnwglUseFontBitmaps;
#define wglUseFontOutlines pfnwglUseFontOutlines;
#define wglDescribeLayerPlane pfnwglDescribeLayerPlane;
#define wglSetLayerPaletteEntries pfnwglSetLayerPaletteEntries;
#define wglGetLayerPaletteEntries pfnwglGetLayerPaletteEntries;
#define wglRealizeLayerPalette pfnwglRealizeLayerPalette;
#define wglSwapLayerBuffers pfnwglSwapLayerBuffers;
#define wglSwapIntervalEXT pfnwglSwapIntervalEXT;
#define wglGetDeviceGammaRampEXT pfnwglGetDeviceGammaRampEXT;
#define wglSetDeviceGammaRampEXT pfnwglSetDeviceGammaRampEXT;
*/
#endif // _WIN_GL_H_