summaryrefslogtreecommitdiff
path: root/src/win_wgl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/win_wgl.c')
-rw-r--r--src/win_wgl.c107
1 files changed, 49 insertions, 58 deletions
diff --git a/src/win_wgl.c b/src/win_wgl.c
index 410199d..f165350 100644
--- a/src/win_wgl.c
+++ b/src/win_wgl.c
@@ -21,26 +21,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "win_glimp.h"
#include "win_wgl.h"
-//void ( APIENTRY * qglDrawBuffer )(GLenum mode);
-const GLubyte * ( APIENTRY * qglGetString )(GLenum name);
+void ( APIENTRY * qwglDrawBuffer )(GLenum mode);
+const GLubyte * ( APIENTRY * qwglGetString )(GLenum name);
int ( WINAPI * qwglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *);
-int ( WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
-//int ( WINAPI * qwglGetPixelFormat)(HDC);
-BOOL ( WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
-BOOL ( WINAPI * qwglSwapBuffers)(HDC);
+int ( WINAPI * qwglDescribePixelFormat )(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
+BOOL ( WINAPI * qwglSetPixelFormat )(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
+BOOL ( WINAPI * qwglSwapBuffers )(HDC);
-//BOOL ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);
-HGLRC ( WINAPI * qwglCreateContext)(HDC);
-BOOL ( WINAPI * qwglDeleteContext)(HGLRC);
-//HGLRC ( WINAPI * qwglGetCurrentContext)(VOID);
-//HDC ( WINAPI * qwglGetCurrentDC)(VOID);
-PROC ( WINAPI * qwglGetProcAddress)(LPCSTR);
-BOOL ( WINAPI * qwglMakeCurrent)(HDC, HGLRC);
+HGLRC ( WINAPI * qwglCreateContext )(HDC);
+BOOL ( WINAPI * qwglDeleteContext )(HGLRC);
+PROC ( WINAPI * qwglGetProcAddress )(LPCSTR);
+BOOL ( WINAPI * qwglMakeCurrent )(HDC, HGLRC);
-BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );
-//BOOL ( WINAPI * qwglGetDeviceGammaRampEXT)( unsigned char *, unsigned char *, unsigned char * );
-//BOOL ( WINAPI * qwglSetDeviceGammaRampEXT)( const unsigned char *, const unsigned char *, const unsigned char * );
+BOOL ( WINAPI * qwglSwapIntervalEXT )(int interval);
void WGL_Shutdown( void ) {
if( glw.hinstOpenGL ) {
@@ -48,73 +42,70 @@ void WGL_Shutdown( void ) {
glw.hinstOpenGL = NULL;
}
- //qglDrawBuffer = NULL;
- qglGetString = NULL;
+ qwglDrawBuffer = NULL;
+ qwglGetString = NULL;
qwglChoosePixelFormat = NULL;
qwglDescribePixelFormat = NULL;
- //qwglGetPixelFormat = NULL;
qwglSetPixelFormat = NULL;
qwglSwapBuffers = NULL;
- //qwglCopyContext = NULL;
qwglCreateContext = NULL;
qwglDeleteContext = NULL;
- //qwglGetCurrentContext = NULL;
- //qwglGetCurrentDC = NULL;
qwglGetProcAddress = NULL;
qwglMakeCurrent = NULL;
- qwglSwapIntervalEXT = NULL;
- //qwglGetDeviceGammaRampEXT = NULL;
- //qwglSetDeviceGammaRampEXT = NULL;
+ WGL_ShutdownExtensions( ~0 );
}
-
-#define GPA( x ) do { \
- q ## x = ( void * )GetProcAddress( glw.hinstOpenGL, #x ); \
- if( !q ## x ) { \
- Com_DPrintf( " %s ", #x ); \
- return qfalse; \
- } \
- } while( 0 )
+#define GPA( x ) ( void * )GetProcAddress( glw.hinstOpenGL, x );
qboolean WGL_Init( const char *dllname ) {
if( ( glw.hinstOpenGL = LoadLibrary( dllname ) ) == NULL ) {
return qfalse;
}
- //GPA( glDrawBuffer );
- GPA( glGetString );
-
- //GPA( wglCopyContext );
- GPA( wglCreateContext );
- //GPA( wglCreateLayerContext );
- GPA( wglDeleteContext );
- //GPA( wglDescribeLayerPlane );
- //GPA( wglGetCurrentContext );
- //GPA( wglGetCurrentDC );
- //GPA( wglGetLayerPaletteEntries );
- GPA( wglGetProcAddress );
- GPA( wglMakeCurrent );
- //GPA( wglRealizeLayerPalette );
- //GPA( wglSetLayerPaletteEntries );
- //GPA( wglShareLists );
- //GPA( wglSwapLayerBuffers );
+ qwglDrawBuffer = GPA( "glDrawBuffer" );
+ qwglGetString = GPA( "glGetString" );
- GPA( wglChoosePixelFormat );
- GPA( wglDescribePixelFormat );
- //GPA( wglGetPixelFormat );
- GPA( wglSetPixelFormat );
- GPA( wglSwapBuffers );
+ qwglChoosePixelFormat = GPA( "wglChoosePixelFormat" );
+ qwglDescribePixelFormat = GPA( "wglDescribePixelFormat" );
+ qwglSetPixelFormat = GPA( "wglSetPixelFormat" );
+ qwglSwapBuffers = GPA( "wglSwapBuffers" );
- qwglSwapIntervalEXT = NULL;
- //qwglGetDeviceGammaRampEXT = NULL;
- //qwglSetDeviceGammaRampEXT = NULL;
+ qwglCreateContext = GPA( "wglCreateContext" );
+ qwglDeleteContext = GPA( "wglDeleteContext" );
+ qwglGetProcAddress = GPA( "wglGetProcAddress" );
+ qwglMakeCurrent = GPA( "wglMakeCurrent" );
return qtrue;
}
+#undef GPA
+
+void WGL_ShutdownExtensions( unsigned mask ) {
+ if( mask & QWGL_EXT_swap_control ) {
+ qwglSwapIntervalEXT = NULL;
+ }
+}
+
+#define GPA( x ) ( void * )qwglGetProcAddress( x )
+
+void WGL_InitExtensions( unsigned mask ) {
+ if( mask & QWGL_EXT_swap_control ) {
+ qwglSwapIntervalEXT = GPA( "wglSwapIntervalEXT" );
+ }
+}
#undef GPA
+unsigned WGL_ParseExtensionString( const char *s ) {
+ // must match defines in win_wgl.h!
+ static const char *const extnames[] = {
+ "WGL_EXT_swap_control",
+ NULL
+ };
+
+ return Com_ParseExtensionString( s, extnames );
+}
+