From e3c5d73abe8c6a6a1f3edd8b29315412be890aeb Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 13 Apr 2012 02:00:45 +0000 Subject: [PATCH] Removed dynamic OpenGL code from Windows and updated extensions. --- common/opengl.cpp | 213 +++++++++-------------------------- common/opengl.h | 274 +++++++++++++++------------------------------ common/piece.cpp | 37 ------ win/Print.cpp | 38 +++---- win/Stdafx.h | 2 +- win/System.cpp | 22 ++-- win/Terrwnd.cpp | 41 ++++--- win/Tools.cpp | 12 +- win/aboutdlg.cpp | 2 +- win/glwindow.cpp | 25 +++-- win/leocad.vcxproj | 4 +- win/win_gl.cpp | 152 ++----------------------- win/win_gl.h | 101 ----------------- 13 files changed, 222 insertions(+), 701 deletions(-) delete mode 100755 win/win_gl.h diff --git a/common/opengl.cpp b/common/opengl.cpp index cc8a8901..44007236 100755 --- a/common/opengl.cpp +++ b/common/opengl.cpp @@ -8,14 +8,15 @@ #include "opengl.h" // These functions should be defined in (system)_gl.cpp -bool Sys_GLOpenLibrary (const char* libname); -void Sys_GLCloseLibrary (); -void* Sys_GLGetProc (const char *symbol); -void* Sys_GLGetExtension (const char *symbol); +bool Sys_GLOpenLibrary(const char* libname); +void Sys_GLCloseLibrary(); +void* Sys_GLGetProc(const char *symbol); +void* Sys_GLGetExtension(const char *symbol); // ============================================================================= // OpenGL Function pointers +#ifdef LC_OPENGL_DYNAMIC PFNGLCLEARINDEX pfnglClearIndex; PFNGLCLEARCOLOR pfnglClearColor; PFNGLCLEAR pfnglClear; @@ -352,45 +353,19 @@ PFNGLINITNAMES pfnglInitNames; PFNGLLOADNAME pfnglLoadName; PFNGLPUSHNAME pfnglPushName; PFNGLPOPNAME pfnglPopName; +#endif // LC_OPENGL_DYNAMIC -PFNGLACTIVETEXTUREARB pfnglActiveTextureARB; -PFNGLCLIENTACTIVETEXTUREARB pfnglClientActiveTextureARB; -PFNGLMULTITEXCOORD1DARB pfnglMultiTexCoord1dARB; -PFNGLMULTITEXCOORD1DVARB pfnglMultiTexCoord1dvARB; -PFNGLMULTITEXCOORD1FARB pfnglMultiTexCoord1fARB; -PFNGLMULTITEXCOORD1FVARB pfnglMultiTexCoord1fvARB; -PFNGLMULTITEXCOORD1IARB pfnglMultiTexCoord1iARB; -PFNGLMULTITEXCOORD1IVARB pfnglMultiTexCoord1ivARB; -PFNGLMULTITEXCOORD1SARB pfnglMultiTexCoord1sARB; -PFNGLMULTITEXCOORD1SVARB pfnglMultiTexCoord1svARB; -PFNGLMULTITEXCOORD2DARB pfnglMultiTexCoord2dARB; -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; +GLBINDBUFFERARBPROC glBindBufferARB; +GLDELETEBUFFERSARBPROC glDeleteBuffersARB; +GLGENBUFFERSARBPROC glGenBuffersARB; +GLISBUFFERARBPROC glIsBufferARB; +GLBUFFERDATAARBPROC glBufferDataARB; +GLBUFFERSUBDATAARBPROC glBufferSubDataARB; +GLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB; +GLMAPBUFFERARBPROC glMapBufferARB; +GLUNMAPBUFFERARBPROC glUnmapBufferARB; +GLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB; +GLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB; // ============================================================================= // Initialization functions @@ -399,6 +374,7 @@ void GL_Shutdown () { Sys_GLCloseLibrary (); +#ifdef LC_OPENGL_DYNAMIC pfnglClearIndex = NULL; pfnglClearColor = NULL; pfnglClear = NULL; @@ -735,45 +711,19 @@ void GL_Shutdown () pfnglLoadName = NULL; pfnglPushName = NULL; pfnglPopName = NULL; +#endif // LC_OPENGL_DYNAMIC - pfnglActiveTextureARB = NULL; - pfnglClientActiveTextureARB = NULL; - pfnglMultiTexCoord1dARB = NULL; - pfnglMultiTexCoord1dvARB = NULL; - pfnglMultiTexCoord1fARB = NULL; - pfnglMultiTexCoord1fvARB = NULL; - pfnglMultiTexCoord1iARB = NULL; - pfnglMultiTexCoord1ivARB = NULL; - pfnglMultiTexCoord1sARB = NULL; - pfnglMultiTexCoord1svARB = NULL; - pfnglMultiTexCoord2dARB = 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; + glBindBufferARB = NULL; + glDeleteBuffersARB = NULL; + glGenBuffersARB = NULL; + glIsBufferARB = NULL; + glBufferDataARB = NULL; + glBufferSubDataARB = NULL; + glGetBufferSubDataARB = NULL; + glMapBufferARB = NULL; + glUnmapBufferARB = NULL; + glGetBufferParameterivARB = NULL; + glGetBufferPointervARB = NULL; } bool GL_Initialize (const char* libname) @@ -784,6 +734,7 @@ bool GL_Initialize (const char* libname) return false; } +#ifdef LC_OPENGL_DYNAMIC pfnglClearIndex = (PFNGLCLEARINDEX) Sys_GLGetProc ("glClearIndex"); pfnglClearColor = (PFNGLCLEARCOLOR) Sys_GLGetProc ("glClearColor"); pfnglClear = (PFNGLCLEAR) Sys_GLGetProc ("glClear"); @@ -1120,6 +1071,7 @@ bool GL_Initialize (const char* libname) pfnglLoadName = (PFNGLLOADNAME) Sys_GLGetProc ("glLoadName"); pfnglPushName = (PFNGLPUSHNAME) Sys_GLGetProc ("glPushName"); pfnglPopName = (PFNGLPOPNAME) Sys_GLGetProc ("glPopName"); +#endif // LC_OPENGL_DYNAMIC return true; } @@ -1127,10 +1079,7 @@ bool GL_Initialize (const char* libname) // ============================================================================= // Extensions support -static GLint GL_MultiTextures = 1; -static bool GL_CompiledVertexArrays = false; -static bool GL_ClampToEdge = false; -static bool GL_PointParameters = false; +bool GL_VertexBufferObject = false; static bool GL_ExtensionSupported (const char *extension) { @@ -1167,88 +1116,26 @@ static bool GL_ExtensionSupported (const char *extension) 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. -bool GL_InitializeExtensions () +bool GL_InitializeExtensions() { - if (GL_ExtensionSupported ("GL_ARB_multitexture")) - { - pfnglActiveTextureARB = (PFNGLACTIVETEXTUREARB) Sys_GLGetExtension ("glActiveTextureARB"); - pfnglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARB) Sys_GLGetExtension ("glClientActiveTextureARB"); - pfnglMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARB) Sys_GLGetExtension ("glMultiTexCoord1dARB"); - pfnglMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARB) Sys_GLGetExtension ("glMultiTexCoord1dvARB"); - pfnglMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARB) Sys_GLGetExtension ("glMultiTexCoord1fARB"); - pfnglMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARB) Sys_GLGetExtension ("glMultiTexCoord1fvARB"); - pfnglMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARB) Sys_GLGetExtension ("glMultiTexCoord1iARB"); - pfnglMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARB) Sys_GLGetExtension ("glMultiTexCoord1ivARB"); - pfnglMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARB) Sys_GLGetExtension ("glMultiTexCoord1sARB"); - pfnglMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARB) Sys_GLGetExtension ("glMultiTexCoord1svARB"); - pfnglMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARB) Sys_GLGetExtension ("glMultiTexCoord2dARB"); - pfnglMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARB) Sys_GLGetExtension ("glMultiTexCoord2dvARB"); - 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_ARB_vertex_buffer_object")) + { + glBindBufferARB = (GLBINDBUFFERARBPROC)Sys_GLGetExtension("glBindBufferARB"); + glDeleteBuffersARB = (GLDELETEBUFFERSARBPROC)Sys_GLGetExtension("glDeleteBuffersARB"); + glGenBuffersARB = (GLGENBUFFERSARBPROC)Sys_GLGetExtension("glGenBuffersARB"); + glIsBufferARB = (GLISBUFFERARBPROC)Sys_GLGetExtension("glIsBufferARB"); + glBufferDataARB = (GLBUFFERDATAARBPROC)Sys_GLGetExtension("glBufferDataARB"); + glBufferSubDataARB = (GLBUFFERSUBDATAARBPROC)Sys_GLGetExtension("glBufferSubDataARB"); + glGetBufferSubDataARB = (GLGETBUFFERSUBDATAARBPROC)Sys_GLGetExtension("glGetBufferSubDataARB"); + glMapBufferARB = (GLMAPBUFFERARBPROC)Sys_GLGetExtension("glMapBufferARB"); + glUnmapBufferARB = (GLUNMAPBUFFERARBPROC)Sys_GLGetExtension("glUnmapBufferARB"); + glGetBufferParameterivARB = (GLGETBUFFERPARAMETERIVARBPROC)Sys_GLGetExtension("glGetBufferParameterivARB"); + glGetBufferPointervARB = (GLGETBUFFERPOINTERVARBPROC)Sys_GLGetExtension("glGetBufferPointervARB"); + GL_VertexBufferObject = true; + } - 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; } // ============================================================================= diff --git a/common/opengl.h b/common/opengl.h index 32067aa5..731a444d 100755 --- a/common/opengl.h +++ b/common/opengl.h @@ -1,17 +1,11 @@ #ifndef _OPENGL_H_ #define _OPENGL_H_ -#ifdef LC_WINDOWS -#include -#include "win_gl.h" -#else -#define APIENTRY -#endif - #ifdef LC_LINUX #include #include #include "linux_gl.h" +#define LC_OPENGL_DYNAMIC 1 #endif #ifdef LC_MACOSX @@ -19,24 +13,30 @@ #include #endif -//#include // TODO: remove all glu calls +#ifndef APIENTRY +#define APIENTRY +#endif + void gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz); void gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); -bool GL_Initialize (const char* libname); -void GL_Shutdown (); -bool GL_InitializeExtensions (); +bool GL_Initialize(const char* libname); +void GL_Shutdown(); +bool GL_InitializeExtensions(); -int GL_GetMultiTextures (); -bool GL_HasCompiledVertexArrays (); -bool GL_HasClampToEdge (); -bool GL_HasPointParameters (); +inline bool GL_HasVertexBufferObject() +{ + extern bool GL_VertexBufferObject; + return GL_VertexBufferObject; +} // ============================================================================= // OpenGL functions typedefs +#ifdef LC_OPENGL_DYNAMIC + // Miscellaneous typedef void (APIENTRY *PFNGLCLEARINDEX) (GLfloat c); 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 *PFNGLPOPNAME) (void); -// GL_ARB_multitexture -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); +#endif // LC_OPENGL_DYNAMIC -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#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 +#include +#ifndef GL_VERSION_1_5 +// GL types for handling large vertex buffer objects +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; #endif -// GL_EXT_point_parameters -typedef void (APIENTRY *PFNGLPOINTPARAMETERFEXT) (GLenum pname, GLfloat param); -typedef void (APIENTRY *PFNGLPOINTPARAMETERFVEXT) (GLenum pname, const GLfloat *params); - -#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 +#ifndef GL_ARB_vertex_buffer_object +// GL types for handling large vertex buffer objects +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; #endif -// GL_EXT_compiled_vertex_array -typedef void (APIENTRY *PFNGLLOCKARRAYSEXT) (GLint first, GLsizei count); -typedef void (APIENTRY *PFNGLUNLOCKARRAYSEXT) (void); - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#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 -// GL_SGIS_texture_edge_clamp -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F +// GL_ARB_vertex_buffer_object +#ifndef GL_ARB_vertex_buffer_object +#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 // ============================================================================= // OpenGL extern declarations +#ifdef LC_OPENGL_DYNAMIC + extern PFNGLCLEARINDEX pfnglClearIndex; extern PFNGLCLEARCOLOR pfnglClearColor; extern PFNGLCLEAR pfnglClear; @@ -844,48 +808,25 @@ extern PFNGLLOADNAME pfnglLoadName; extern PFNGLPUSHNAME pfnglPushName; extern PFNGLPOPNAME pfnglPopName; -extern PFNGLACTIVETEXTUREARB pfnglActiveTextureARB; -extern PFNGLCLIENTACTIVETEXTUREARB pfnglClientActiveTextureARB; -extern PFNGLMULTITEXCOORD1DARB pfnglMultiTexCoord1dARB; -extern PFNGLMULTITEXCOORD1DVARB pfnglMultiTexCoord1dvARB; -extern PFNGLMULTITEXCOORD1FARB pfnglMultiTexCoord1fARB; -extern PFNGLMULTITEXCOORD1FVARB pfnglMultiTexCoord1fvARB; -extern PFNGLMULTITEXCOORD1IARB pfnglMultiTexCoord1iARB; -extern PFNGLMULTITEXCOORD1IVARB pfnglMultiTexCoord1ivARB; -extern PFNGLMULTITEXCOORD1SARB pfnglMultiTexCoord1sARB; -extern PFNGLMULTITEXCOORD1SVARB pfnglMultiTexCoord1svARB; -extern PFNGLMULTITEXCOORD2DARB pfnglMultiTexCoord2dARB; -extern PFNGLMULTITEXCOORD2DVARB pfnglMultiTexCoord2dvARB; -extern PFNGLMULTITEXCOORD2FARB pfnglMultiTexCoord2fARB; -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; +#endif // LC_OPENGL_DYNAMIC + +extern GLBINDBUFFERARBPROC glBindBufferARB; +extern GLDELETEBUFFERSARBPROC glDeleteBuffersARB; +extern GLGENBUFFERSARBPROC glGenBuffersARB; +extern GLISBUFFERARBPROC glIsBufferARB; +extern GLBUFFERDATAARBPROC glBufferDataARB; +extern GLBUFFERSUBDATAARBPROC glBufferSubDataARB; +extern GLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB; +extern GLMAPBUFFERARBPROC glMapBufferARB; +extern GLUNMAPBUFFERARBPROC glUnmapBufferARB; +extern GLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB; +extern GLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB; // ============================================================================= // Replace OpenGL function names with the dynamic functions +#ifdef LC_OPENGL_DYNAMIC + #define glClearIndex pfnglClearIndex #define glClearColor pfnglClearColor #define glClear pfnglClear @@ -1223,43 +1164,6 @@ extern PFNGLUNLOCKARRAYSEXT pfnglUnlockArraysEXT; #define glPushName pfnglPushName #define glPopName pfnglPopName -#define glActiveTextureARB pfnglActiveTextureARB -#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 // LC_OPENGL_DYNAMIC #endif // _OPENGL_H_ diff --git a/common/piece.cpp b/common/piece.cpp index dc6e2c8e..7a4e80db 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -56,19 +56,9 @@ inline static void SetCurrentColor(unsigned char nColor, bool bLighting) ///////////////////////////////////////////////////////////////////////////// // Piece construction/destruction -static bool lockarrays = false; - Piece::Piece(PieceInfo* pPieceInfo) : Object (LC_OBJECT_PIECE) { - static bool first_time = true; - - if (first_time) - { - first_time = false; - lockarrays = GL_HasCompiledVertexArrays (); - } - m_pNext = NULL; m_pPieceInfo = pPieceInfo; m_nState = 0; @@ -1207,17 +1197,12 @@ void Piece::Render(bool bLighting, bool bEdges) while (colors--) { - bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES); - if (*info == LC_COL_DEFAULT) SetCurrentColor(mColorIndex, bLighting); else SetCurrentColor((unsigned char)*info, bLighting); info++; - if (lock) - glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); - if (*info) { 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 (lock) - glUnlockArraysEXT(); - if (m_nState & LC_PIECE_FOCUSED) lcSetColorFocused(); else lcSetColorSelected(); - if (lock) - glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); - glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1); } else @@ -1259,9 +1238,6 @@ void Piece::Render(bool bLighting, bool bEdges) } else info++; - - if (lock) - glUnlockArraysEXT(); } } else @@ -1272,17 +1248,12 @@ void Piece::Render(bool bLighting, bool bEdges) while (colors--) { - bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES); - if (*info == LC_COL_DEFAULT) SetCurrentColor(mColorIndex, bLighting); else SetCurrentColor((unsigned char)*info, bLighting); info++; - if (lock) - glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); - if (*info) { 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 (lock) - glUnlockArraysEXT(); if (m_nState & LC_PIECE_FOCUSED) lcSetColorFocused(); else lcSetColorSelected(); - if (lock) - glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); - glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1); } else @@ -1323,9 +1289,6 @@ void Piece::Render(bool bLighting, bool bEdges) } else info++; - - if (lock) - glUnlockArraysEXT(); } } diff --git a/win/Print.cpp b/win/Print.cpp index 14d1bf77..e9df5bef 100644 --- a/win/Print.cpp +++ b/win/Print.cpp @@ -164,31 +164,31 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame) // Creating a DIB surface HBITMAP hBm, hBmOld; - hBm = CreateDIBSection(pView->GetDC()->GetSafeHdc(), &bi, DIB_RGB_COLORS, + hBm = CreateDIBSection(pView->GetDC()->GetSafeHdc(), &bi, DIB_RGB_COLORS, (void **)&lpbi, NULL, (DWORD)0); if (!hBm) return; - - // Selecting the DIB Surface + + // Selecting the DIB Surface hBmOld = (HBITMAP)::SelectObject(pMemDC->GetSafeHdc(), hBm); if (!hBmOld) return; - - // Setting up a Pixel format for the DIB surface + + // Setting up a Pixel format for the DIB surface 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 }; - int pixelformat = OpenGLChoosePixelFormat(pMemDC->m_hDC, &pfd); - OpenGLDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - OpenGLSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); + int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd); + DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); // Creating a OpenGL context - HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc()); + HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc()); // Setting up the current OpenGL context - pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); + wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); double aspect = (float)w/(float)h; glMatrixMode(GL_MODELVIEW); glViewport(0, 0, w, h); @@ -373,8 +373,8 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWndEx* pMainFrame) free(previous); } - pfnwglMakeCurrent(NULL, NULL); - pfnwglDeleteContext(hmemrc); + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hmemrc); SelectObject(pMemDC->GetSafeHdc(), hBmOld); DeleteObject(hBm); 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, 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); - OpenGLDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - OpenGLSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); - HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc()); - pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); + int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd); + DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd); + HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc()); + wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc); double aspect = (float)picw/(float)h; glMatrixMode(GL_MODELVIEW); glViewport(0, 0, picw, h); @@ -773,8 +773,8 @@ static void PrintPiecesThread(void* pv) free(previous); } - pfnwglMakeCurrent(NULL, NULL); - pfnwglDeleteContext(hmemrc); + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hmemrc); SelectObject(pMemDC->GetSafeHdc(), hBmOld); DeleteObject(hBm); delete pMemDC; diff --git a/win/Stdafx.h b/win/Stdafx.h index d16ea699..9dd64141 100644 --- a/win/Stdafx.h +++ b/win/Stdafx.h @@ -31,7 +31,7 @@ #include // MFC support for ribbons and control bars -#include "opengl.h" +#include #define IDT_LC_SAVETIMER (WM_USER+200) #define IDT_LC_WHEELTIMER (WM_USER+201) diff --git a/win/System.cpp b/win/System.cpp index 7e53f546..58901260 100644 --- a/win/System.cpp +++ b/win/System.cpp @@ -1373,7 +1373,7 @@ bool SystemDoDialog(int nMode, void* param) case LC_DLG_ABOUT: { CAboutDlg dlg; - dlg.m_hViewDC = pfnwglGetCurrentDC(); + dlg.m_hViewDC = wglGetCurrentDC(); dlg.DoModal(); } break; } @@ -1400,8 +1400,8 @@ void* Sys_StartMemoryRender(int width, int height) CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CView* pView = pFrame->GetActiveView(); CDC* pDC = pView->GetDC(); - render->oldhdc = pfnwglGetCurrentDC(); - render->oldhrc = pfnwglGetCurrentContext(); + render->oldhdc = wglGetCurrentDC(); + render->oldhrc = wglGetCurrentContext(); render->hdc = CreateCompatibleDC(pDC->m_hDC); // Preparing bitmap header for DIB section @@ -1419,7 +1419,7 @@ void* Sys_StartMemoryRender(int width, int height) // Creating a DIB surface LPVOID lpBits; - render->hbm = CreateDIBSection(pDC->GetSafeHdc(), &bi, DIB_RGB_COLORS, (void**)&lpBits, NULL, (DWORD)0); + render->hbm = CreateDIBSection(pDC->GetSafeHdc(), &bi, DIB_RGB_COLORS, (void**)&lpBits, NULL, (DWORD)0); render->oldhbm = (HBITMAP)::SelectObject(render->hdc, render->hbm); PIXELFORMATDESCRIPTOR pfd = { @@ -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, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; - int pixelformat = OpenGLChoosePixelFormat(render->hdc, &pfd); - OpenGLDescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - OpenGLSetPixelFormat(render->hdc, pixelformat, &pfd); - render->hrc = pfnwglCreateContext(render->hdc); - pfnwglMakeCurrent(render->hdc, render->hrc); + int pixelformat = ChoosePixelFormat(render->hdc, &pfd); + DescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + SetPixelFormat(render->hdc, pixelformat, &pfd); + render->hrc = wglCreateContext(render->hdc); + wglMakeCurrent(render->hdc, render->hrc); return render; } @@ -1440,8 +1440,8 @@ void Sys_FinishMemoryRender(void* param) { LC_RENDER* render = (LC_RENDER*)param; - pfnwglMakeCurrent (render->oldhdc, render->oldhrc); - pfnwglDeleteContext(render->hrc); + wglMakeCurrent (render->oldhdc, render->oldhrc); + wglDeleteContext(render->hrc); SelectObject(render->hdc, render->oldhbm); DeleteObject(render->hbm); DeleteDC(render->hdc); diff --git a/win/Terrwnd.cpp b/win/Terrwnd.cpp index 61ddca9a..e20fc0c2 100644 --- a/win/Terrwnd.cpp +++ b/win/Terrwnd.cpp @@ -59,8 +59,8 @@ void CTerrainWnd::OnPaint() { CPaintDC dc(this); // device context for painting - HDC oldDC = pfnwglGetCurrentDC(); - HGLRC oldRC = pfnwglGetCurrentContext(); + HDC oldDC = wglGetCurrentDC(); + HGLRC oldRC = wglGetCurrentContext(); if (m_pPalette) { @@ -68,7 +68,7 @@ void CTerrainWnd::OnPaint() 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); @@ -79,9 +79,8 @@ void CTerrainWnd::OnPaint() m_pTerrain->Render(m_pCamera, aspect); - glFlush(); - OpenGLSwapBuffers (dc.m_hDC); - pfnwglMakeCurrent (oldDC, oldRC); + SwapBuffers(dc.m_hDC); + wglMakeCurrent(oldDC, oldRC); } void CTerrainWnd::OnSize(UINT nType, int cx, int cy) @@ -105,7 +104,7 @@ void CTerrainWnd::OnDestroy() } if (m_hglRC) - pfnwglDeleteContext(m_hglRC); + wglDeleteContext(m_hglRC); if (m_pDC) delete m_pDC; @@ -116,9 +115,9 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; - - m_pDC = new CClientDC(this); - ASSERT(m_pDC != NULL); + + m_pDC = new CClientDC(this); + ASSERT(m_pDC != NULL); // Fill in the Pixel Format Descriptor PIXELFORMATDESCRIPTOR pfd; @@ -132,11 +131,11 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) pfd.cDepthBits = 32; pfd.iLayerType = PFD_MAIN_PLANE; - int nPixelFormat = OpenGLChoosePixelFormat(m_pDC->m_hDC, &pfd); + int nPixelFormat = ChoosePixelFormat(m_pDC->m_hDC, &pfd); if (nPixelFormat == 0) return -1; - if (!OpenGLSetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd)) + if (!SetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd)) return -1; m_pPalette = new CPalette; @@ -152,13 +151,13 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) } // Create a rendering context. - m_hglRC = pfnwglCreateContext(m_pDC->m_hDC); + m_hglRC = wglCreateContext(m_pDC->m_hDC); if (!m_hglRC) return -1; - HDC oldDC = pfnwglGetCurrentDC(); - HGLRC oldRC = pfnwglGetCurrentContext(); - pfnwglMakeCurrent (m_pDC->m_hDC, m_hglRC); + HDC oldDC = wglGetCurrentDC(); + HGLRC oldRC = wglGetCurrentContext(); + wglMakeCurrent (m_pDC->m_hDC, m_hglRC); // Initialize OpenGL the way we want it. 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_CULL_FACE); - pfnwglMakeCurrent(oldDC, oldRC); + wglMakeCurrent(oldDC, oldRC); return 0; } void CTerrainWnd::LoadTexture(bool linear) { - HDC oldDC = pfnwglGetCurrentDC(); - HGLRC oldRC = pfnwglGetCurrentContext(); + HDC oldDC = wglGetCurrentDC(); + HGLRC oldRC = wglGetCurrentContext(); - pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC); + wglMakeCurrent(m_pDC->m_hDC, m_hglRC); m_pTerrain->LoadTexture(linear); - pfnwglMakeCurrent(oldDC, oldRC); + wglMakeCurrent(oldDC, oldRC); } void CTerrainWnd::OnLButtonDown(UINT nFlags, CPoint point) diff --git a/win/Tools.cpp b/win/Tools.cpp index 0b89dea5..1d5a1679 100644 --- a/win/Tools.cpp +++ b/win/Tools.cpp @@ -116,10 +116,10 @@ static unsigned char ComponentFromIndex(int i, UINT nbits, UINT shift) unsigned char val = (unsigned char) (i >> shift); switch (nbits) { case 1: val &= 0x1; return oneto8[val]; - case 2: val &= 0x3; return twoto8[val]; - case 3: val &= 0x7; return threeto8[val]; - default: return 0; - } + case 2: val &= 0x3; return twoto8[val]; + case 3: val &= 0x7; return threeto8[val]; + default: return 0; + } } BOOL CreateRGBPalette(HDC hDC, CPalette **ppCPalette) @@ -128,8 +128,8 @@ BOOL CreateRGBPalette(HDC hDC, CPalette **ppCPalette) LOGPALETTE *pPal; WORD n, i; - n = OpenGLGetPixelFormat(hDC); - OpenGLDescribePixelFormat(hDC, n, sizeof(pfd), &pfd); + n = GetPixelFormat(hDC); + DescribePixelFormat(hDC, n, sizeof(pfd), &pfd); if (!(pfd.dwFlags & PFD_NEED_PALETTE)) return FALSE; diff --git a/win/aboutdlg.cpp b/win/aboutdlg.cpp index 0a647ef4..b3ba28d8 100644 --- a/win/aboutdlg.cpp +++ b/win/aboutdlg.cpp @@ -47,7 +47,7 @@ BOOL CAboutDlg::OnInitDialog() // Initialize the OpenGL information box. CString info, tmp; PIXELFORMATDESCRIPTOR pfd; - OpenGLDescribePixelFormat(m_hViewDC, OpenGLGetPixelFormat(m_hViewDC), sizeof(PIXELFORMATDESCRIPTOR), &pfd); + DescribePixelFormat(m_hViewDC, GetPixelFormat(m_hViewDC), sizeof(PIXELFORMATDESCRIPTOR), &pfd); info = ("Pixel Format: "); if (pfd.iPixelType == PFD_TYPE_RGBA) diff --git a/win/glwindow.cpp b/win/glwindow.cpp index 0c47d0b4..b7586c74 100644 --- a/win/glwindow.cpp +++ b/win/glwindow.cpp @@ -1,4 +1,5 @@ #include "lc_global.h" +#include "opengl.h" #include "glwindow.h" #include "tools.h" @@ -7,7 +8,7 @@ struct GLWindowPrivate HGLRC m_hrc; CDC* m_pDC; CPalette* m_pPal; - HWND m_hWnd; + HWND m_hWnd; }; // ============================================================================ @@ -168,11 +169,11 @@ bool GLWindow::CreateFromWindow(void* data) pfd.cDepthBits = 24; 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) return false; - if (!OpenGLSetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) + if (!SetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) return false; prv->m_pPal = new CPalette; @@ -189,14 +190,14 @@ bool GLWindow::CreateFromWindow(void* data) } // 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) return false; if (m_pShare) { GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData; - pfnwglShareLists(share->m_hrc, prv->m_hrc); + wglShareLists(share->m_hrc, prv->m_hrc); } return true; @@ -222,11 +223,11 @@ bool GLWindow::CreateFromBitmap(void* Data) pfd.cDepthBits = 16; 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) return false; - if (!OpenGLSetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) + if (!SetPixelFormat(prv->m_pDC->m_hDC, nPixelFormat, &pfd)) return false; prv->m_pPal = new CPalette; @@ -243,14 +244,14 @@ bool GLWindow::CreateFromBitmap(void* Data) } // 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) return false; if (m_pShare) { GLWindowPrivate *share = (GLWindowPrivate*)m_pShare->m_pData; - pfnwglShareLists(share->m_hrc, prv->m_hrc); + wglShareLists(share->m_hrc, prv->m_hrc); } return true; @@ -270,7 +271,7 @@ void GLWindow::DestroyContext() } if (prv->m_hrc) - pfnwglDeleteContext(prv->m_hrc); + wglDeleteContext(prv->m_hrc); prv->m_hrc = NULL; if (prv->m_pDC) @@ -294,14 +295,14 @@ bool GLWindow::MakeCurrent() 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() { GLWindowPrivate *prv = (GLWindowPrivate*)m_pData; - OpenGLSwapBuffers(prv->m_pDC->m_hDC); + ::SwapBuffers(prv->m_pDC->m_hDC); } void GLWindow::Redraw(bool ForceRedraw) diff --git a/win/leocad.vcxproj b/win/leocad.vcxproj index 4fccb6de..5a212909 100644 --- a/win/leocad.vcxproj +++ b/win/leocad.vcxproj @@ -55,7 +55,7 @@ Windows true - wininet.lib;vfw32.lib + wininet.lib;vfw32.lib;opengl32.lib jpeglib\debug;libpng\debug;zlib\debug;3dsftk\debug @@ -85,7 +85,7 @@ true true true - wininet.lib;vfw32.lib + wininet.lib;vfw32.lib;opengl32.lib jpeglib\release;libpng\release;zlib\release;3dsftk\release true diff --git a/win/win_gl.cpp b/win/win_gl.cpp index 0ec3e75c..1e0bee02 100755 --- a/win/win_gl.cpp +++ b/win/win_gl.cpp @@ -1,173 +1,41 @@ #include "lc_global.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); - else - return pfnwglSwapBuffers (hdc); + return SwapBuffers(hdc); } int OpenGLChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd) { - if (!gl_ignore_GDI) - return ChoosePixelFormat (hdc, ppfd); - else - return pfnwglChoosePixelFormat (hdc, ppfd); + return ChoosePixelFormat(hdc, ppfd); } int OpenGLDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) { - if (!gl_ignore_GDI) - return DescribePixelFormat (hdc, iPixelFormat, nBytes, ppfd); - else - return pfnwglDescribePixelFormat (hdc, iPixelFormat, nBytes, ppfd); + return DescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd); } BOOL OpenGLSetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd) { - if (!gl_ignore_GDI) - return SetPixelFormat (hdc, iPixelFormat, ppfd); - else - return pfnwglSetPixelFormat (hdc, iPixelFormat, ppfd); + return SetPixelFormat(hdc, iPixelFormat, ppfd); } int OpenGLGetPixelFormat(HDC hdc) { - if (!gl_ignore_GDI) - return GetPixelFormat (hdc); - else - return pfnwglGetPixelFormat (hdc); + return GetPixelFormat(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) +bool Sys_GLOpenLibrary(const char* libname) { - return pfnwglGetProcAddress (symbol); -} - -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; } -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; } diff --git a/win/win_gl.h b/win/win_gl.h deleted file mode 100755 index 8a707d2f..00000000 --- a/win/win_gl.h +++ /dev/null @@ -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_