diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/sound/al.c | 7 | ||||
-rw-r--r-- | src/client/sound/qal/dynamic.c (renamed from src/client/sound/qal.c) | 4 | ||||
-rw-r--r-- | src/client/sound/qal/dynamic.h (renamed from src/client/sound/qal.h) | 0 | ||||
-rw-r--r-- | src/client/sound/qal/fixed.c | 74 | ||||
-rw-r--r-- | src/client/sound/qal/fixed.h | 97 | ||||
-rw-r--r-- | src/refresh/gl/gl.h | 7 | ||||
-rw-r--r-- | src/refresh/gl/main.c | 4 | ||||
-rw-r--r-- | src/refresh/gl/qgl/dynamic.c (renamed from src/refresh/gl/qgl.c) | 11 | ||||
-rw-r--r-- | src/refresh/gl/qgl/dynamic.h (renamed from src/refresh/gl/qgl.h) | 17 | ||||
-rw-r--r-- | src/refresh/gl/qgl/fixed.c | 128 | ||||
-rw-r--r-- | src/refresh/gl/qgl/fixed.h | 152 | ||||
-rw-r--r-- | src/unix/sdl/glimp.c | 41 | ||||
-rw-r--r-- | src/unix/sdl/video.h | 4 | ||||
-rw-r--r-- | src/unix/system.c | 10 | ||||
-rw-r--r-- | src/windows/glimp.c | 22 | ||||
-rw-r--r-- | src/windows/system.c | 15 |
16 files changed, 548 insertions, 45 deletions
diff --git a/src/client/sound/al.c b/src/client/sound/al.c index b6bac51..3d07a36 100644 --- a/src/client/sound/al.c +++ b/src/client/sound/al.c @@ -17,7 +17,12 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "sound.h" -#include "qal.h" + +#if USE_FIXED_LIBAL +#include "qal/fixed.h" +#else +#include "qal/dynamic.h" +#endif // translates from AL coordinate system to quake #define AL_UnpackVector(v) -v[1],v[2],-v[0] diff --git a/src/client/sound/qal.c b/src/client/sound/qal/dynamic.c index f91c472..73b79bb 100644 --- a/src/client/sound/qal.c +++ b/src/client/sound/qal/dynamic.c @@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common/cvar.h" #include "common/common.h" #include "common/files.h" -#include "qal.h" +#include "dynamic.h" #include <AL/alc.h> #define QALC_IMP \ @@ -102,7 +102,7 @@ qboolean QAL_Init(void) return qfalse; } -#define QAL(type, func) q##func = Sys_GetProcAddress(handle, #func) +#define QAL(type, func) if ((q##func = Sys_GetProcAddress(handle, #func)) == NULL) goto fail; QALC_IMP QAL_IMP #undef QAL diff --git a/src/client/sound/qal.h b/src/client/sound/qal/dynamic.h index c226e95..c226e95 100644 --- a/src/client/sound/qal.h +++ b/src/client/sound/qal/dynamic.h diff --git a/src/client/sound/qal/fixed.c b/src/client/sound/qal/fixed.c new file mode 100644 index 0000000..48e0e0a --- /dev/null +++ b/src/client/sound/qal/fixed.c @@ -0,0 +1,74 @@ +/* +Copyright (C) 2013 Andrey Nazarov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "shared/shared.h" +#include "common/cvar.h" +#include "common/common.h" +#include "fixed.h" +#include <AL/alc.h> + +static cvar_t *al_device; + +static ALCdevice *device; +static ALCcontext *context; + +void QAL_Shutdown(void) +{ + if (context) { + alcMakeContextCurrent(NULL); + alcDestroyContext(context); + context = NULL; + } + if (device) { + alcCloseDevice(device); + device = NULL; + } + + if (al_device) + al_device->flags &= ~CVAR_SOUND; +} + +qboolean QAL_Init(void) +{ + al_device = Cvar_Get("al_device", "", 0); + + device = alcOpenDevice(al_device->string[0] ? al_device->string : NULL); + if (!device) { + Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string)); + goto fail; + } + + context = alcCreateContext(device, NULL); + if (!context) { + Com_SetLastError("alcCreateContext failed"); + goto fail; + } + + if (!alcMakeContextCurrent(context)) { + Com_SetLastError("alcMakeContextCurrent failed"); + goto fail; + } + + al_device->flags |= CVAR_SOUND; + + return qtrue; + +fail: + QAL_Shutdown(); + return qfalse; +} diff --git a/src/client/sound/qal/fixed.h b/src/client/sound/qal/fixed.h new file mode 100644 index 0000000..f028d62 --- /dev/null +++ b/src/client/sound/qal/fixed.h @@ -0,0 +1,97 @@ +/* +Copyright (C) 2013 Andrey Nazarov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License qalong +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <AL/al.h> + +#define qalEnable alEnable +#define qalDisable alDisable +#define qalIsEnabled alIsEnabled +#define qalGetString alGetString +#define qalGetBooleanv alGetBooleanv +#define qalGetIntegerv alGetIntegerv +#define qalGetFloatv alGetFloatv +#define qalGetDoublev alGetDoublev +#define qalGetBoolean alGetBoolean +#define qalGetInteger alGetInteger +#define qalGetFloat alGetFloat +#define qalGetDouble alGetDouble +#define qalGetError alGetError +#define qalIsExtensionPresent alIsExtensionPresent +#define qalGetProcAddress alGetProcAddress +#define qalGetEnumValue alGetEnumValue +#define qalListenerf alListenerf +#define qalListener3f alListener3f +#define qalListenerfv alListenerfv +#define qalListeneri alListeneri +#define qalListener3i alListener3i +#define qalListeneriv alListeneriv +#define qalGetListenerf alGetListenerf +#define qalGetListener3f alGetListener3f +#define qalGetListenerfv alGetListenerfv +#define qalGetListeneri alGetListeneri +#define qalGetListener3i alGetListener3i +#define qalGetListeneriv alGetListeneriv +#define qalGenSources alGenSources +#define qalDeleteSources alDeleteSources +#define qalIsSource alIsSource +#define qalSourcef alSourcef +#define qalSource3f alSource3f +#define qalSourcefv alSourcefv +#define qalSourcei alSourcei +#define qalSource3i alSource3i +#define qalSourceiv alSourceiv +#define qalGetSourcef alGetSourcef +#define qalGetSource3f alGetSource3f +#define qalGetSourcefv alGetSourcefv +#define qalGetSourcei alGetSourcei +#define qalGetSource3i alGetSource3i +#define qalGetSourceiv alGetSourceiv +#define qalSourcePlayv alSourcePlayv +#define qalSourceStopv alSourceStopv +#define qalSourceRewindv alSourceRewindv +#define qalSourcePausev alSourcePausev +#define qalSourcePlay alSourcePlay +#define qalSourceStop alSourceStop +#define qalSourceRewind alSourceRewind +#define qalSourcePause alSourcePause +#define qalSourceQueueBuffers alSourceQueueBuffers +#define qalSourceUnqueueBuffers alSourceUnqueueBuffers +#define qalGenBuffers alGenBuffers +#define qalDeleteBuffers alDeleteBuffers +#define qalIsBuffer alIsBuffer +#define qalBufferData alBufferData +#define qalBufferf alBufferf +#define qalBuffer3f alBuffer3f +#define qalBufferfv alBufferfv +#define qalBufferi alBufferi +#define qalBuffer3i alBuffer3i +#define qalBufferiv alBufferiv +#define qalGetBufferf alGetBufferf +#define qalGetBuffer3f alGetBuffer3f +#define qalGetBufferfv alGetBufferfv +#define qalGetBufferi alGetBufferi +#define qalGetBuffer3i alGetBuffer3i +#define qalGetBufferiv alGetBufferiv +#define qalDopplerFactor alDopplerFactor +#define qalDopplerVelocity alDopplerVelocity +#define qalSpeedOfSound alSpeedOfSound +#define qalDistanceModel alDistanceModel + +qboolean QAL_Init(void); +void QAL_Shutdown(void); + diff --git a/src/refresh/gl/gl.h b/src/refresh/gl/gl.h index 09d2c70..7edb42a 100644 --- a/src/refresh/gl/gl.h +++ b/src/refresh/gl/gl.h @@ -29,7 +29,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "refresh/images.h" #include "refresh/models.h" #include "system/hunk.h" -#include "qgl.h" + +#if USE_FIXED_LIBGL +#include "qgl/fixed.h" +#else +#include "qgl/dynamic.h" +#endif /* * gl_main.c diff --git a/src/refresh/gl/main.c b/src/refresh/gl/main.c index adcbb4e..582ce6b 100644 --- a/src/refresh/gl/main.c +++ b/src/refresh/gl/main.c @@ -980,7 +980,9 @@ qboolean R_Init(qboolean total) } // initialize our QGL dynamic bindings - QGL_Init(); + if (!QGL_Init()) { + goto fail; + } // initialize extensions and get various limits from OpenGL if (!GL_SetupConfig()) { diff --git a/src/refresh/gl/qgl.c b/src/refresh/gl/qgl/dynamic.c index c071ba0..493a1c6 100644 --- a/src/refresh/gl/qgl.c +++ b/src/refresh/gl/qgl/dynamic.c @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "shared/shared.h" #include "common/common.h" #include "client/video.h" -#include "qgl.h" +#include "dynamic.h" // ========================================================== @@ -663,15 +663,16 @@ void QGL_ShutdownExtensions(unsigned mask) #define GCA(x) VID_GetCoreAddr("gl"#x) #define GPA(x) VID_GetProcAddr("gl"#x) -void QGL_Init(void) +qboolean QGL_Init(void) { #ifdef _DEBUG -#define QGL(x) qgl##x = dll##x = GCA(x) +#define QGL(x) if ((qgl##x = dll##x = GCA(x)) == NULL) return qfalse; #else -#define QGL(x) qgl##x = GCA(x) +#define QGL(x) if ((qgl##x = GCA(x)) == NULL) return qfalse; #endif QGL_core_IMP #undef QGL + return qtrue; } void QGL_InitExtensions(unsigned mask) @@ -701,7 +702,7 @@ void QGL_InitExtensions(unsigned mask) unsigned QGL_ParseExtensionString(const char *s) { - // must match defines in qgl_api.h! + // must match defines in dynamic.h! static const char *const extnames[] = { "GL_ARB_fragment_program", "GL_ARB_multitexture", diff --git a/src/refresh/gl/qgl.h b/src/refresh/gl/qgl/dynamic.h index ab2abe7..19dfb69 100644 --- a/src/refresh/gl/qgl.h +++ b/src/refresh/gl/qgl/dynamic.h @@ -15,21 +15,12 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -/* -** QGL.H -*/ -#ifndef __QGL_H__ -#define __QGL_H__ +#ifndef QGL_H +#define QGL_H -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include <windows.h> #include <GL/gl.h> #include <GL/glext.h> -#else -#include <GL/gl.h> -#endif #ifndef APIENTRY #define APIENTRY @@ -278,7 +269,7 @@ typedef void (APIENTRY * qglUnlockArraysEXT_t)(void); // ========================================================== -void QGL_Init(void); +qboolean QGL_Init(void); void QGL_Shutdown(void); void QGL_InitExtensions(unsigned mask); void QGL_ShutdownExtensions(unsigned mask); @@ -299,5 +290,5 @@ QGL_ARB_vertex_buffer_object_IMP QGL_EXT_compiled_vertex_array_IMP #undef QGL -#endif +#endif // QGL_H diff --git a/src/refresh/gl/qgl/fixed.c b/src/refresh/gl/qgl/fixed.c new file mode 100644 index 0000000..ae8ec45 --- /dev/null +++ b/src/refresh/gl/qgl/fixed.c @@ -0,0 +1,128 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "shared/shared.h" +#include "common/common.h" +#include "client/video.h" +#include "fixed.h" + +// ========================================================== + +// GL_ARB_fragment_program +PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB; +PFNGLBINDPROGRAMARBPROC qglBindProgramARB; +PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB; +PFNGLGENPROGRAMSARBPROC qglGenProgramsARB; +PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB; +PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB; + +// GL_ARB_multitexture +PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB; +PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB; + +// GL_ARB_vertex_buffer_object +PFNGLBINDBUFFERARBPROC qglBindBufferARB; +PFNGLDELETEBUFFERSARBPROC qglDeleteBuffersARB; +PFNGLGENBUFFERSARBPROC qglGenBuffersARB; +PFNGLBUFFERDATAARBPROC qglBufferDataARB; +PFNGLBUFFERSUBDATAARBPROC qglBufferSubDataARB; + +// GL_EXT_compiled_vertex_array +PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT; +PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT; + +// ========================================================== + +void QGL_ShutdownExtensions(unsigned mask) +{ + if (mask & QGL_ARB_fragment_program) { + qglProgramStringARB = NULL; + qglBindProgramARB = NULL; + qglDeleteProgramsARB = NULL; + qglGenProgramsARB = NULL; + qglProgramEnvParameter4fvARB = NULL; + qglProgramLocalParameter4fvARB = NULL; + } + + if (mask & QGL_ARB_multitexture) { + qglActiveTextureARB = NULL; + qglClientActiveTextureARB = NULL; + } + + if (mask & QGL_ARB_vertex_buffer_object) { + qglBindBufferARB = NULL; + qglDeleteBuffersARB = NULL; + qglGenBuffersARB = NULL; + qglBufferDataARB = NULL; + qglBufferSubDataARB = NULL; + } + + if (mask & QGL_EXT_compiled_vertex_array) { + qglLockArraysEXT = NULL; + qglUnlockArraysEXT = NULL; + } +} + +#define GPA(x) VID_GetProcAddr(x) + +void QGL_InitExtensions(unsigned mask) +{ + if (mask & QGL_ARB_fragment_program) { + qglProgramStringARB = GPA("glProgramStringARB"); + qglBindProgramARB = GPA("glBindProgramARB"); + qglDeleteProgramsARB = GPA("glDeleteProgramsARB"); + qglGenProgramsARB = GPA("glGenProgramsARB"); + qglProgramEnvParameter4fvARB = GPA("glProgramEnvParameter4fvARB"); + qglProgramLocalParameter4fvARB = GPA("glProgramLocalParameter4fvARB"); + } + + if (mask & QGL_ARB_multitexture) { + qglActiveTextureARB = GPA("glActiveTextureARB"); + qglClientActiveTextureARB = GPA("glClientActiveTextureARB"); + } + + if (mask & QGL_ARB_vertex_buffer_object) { + qglBindBufferARB = GPA("glBindBufferARB"); + qglDeleteBuffersARB = GPA("glDeleteBuffersARB"); + qglGenBuffersARB = GPA("glGenBuffersARB"); + qglBufferDataARB = GPA("glBufferDataARB"); + qglBufferSubDataARB = GPA("glBufferSubDataARB"); + } + + if (mask & QGL_EXT_compiled_vertex_array) { + qglLockArraysEXT = GPA("glLockArraysEXT"); + qglUnlockArraysEXT = GPA("glUnlockArraysEXT"); + } +} + +#undef GPA + +unsigned QGL_ParseExtensionString(const char *s) +{ + // must match defines in fixed.h! + static const char *const extnames[] = { + "GL_ARB_fragment_program", + "GL_ARB_multitexture", + "GL_ARB_vertex_buffer_object", + "GL_EXT_compiled_vertex_array", + "GL_EXT_texture_filter_anisotropic", + NULL + }; + + return Com_ParseExtensionString(s, extnames); +} diff --git a/src/refresh/gl/qgl/fixed.h b/src/refresh/gl/qgl/fixed.h new file mode 100644 index 0000000..73b2669 --- /dev/null +++ b/src/refresh/gl/qgl/fixed.h @@ -0,0 +1,152 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef QGL_H +#define QGL_H + +#include <GL/gl.h> +#include <GL/glext.h> + +// ========================================================== + +// subset of OpenGL 1.1 core functions +#define qglAlphaFunc glAlphaFunc +#define qglBindTexture glBindTexture +#define qglBlendFunc glBlendFunc +#define qglClear glClear +#define qglClearColor glClearColor +#define qglClearDepth glClearDepth +#define qglClearStencil glClearStencil +#define qglColor4f glColor4f +#define qglColor4fv glColor4fv +#define qglColorMask glColorMask +#define qglColorPointer glColorPointer +#define qglCopyTexImage2D glCopyTexImage2D +#define qglCopyTexSubImage2D glCopyTexSubImage2D +#define qglCullFace glCullFace +#define qglDeleteTextures glDeleteTextures +#define qglDepthFunc glDepthFunc +#define qglDepthMask glDepthMask +#define qglDepthRange glDepthRange +#define qglDisable glDisable +#define qglDisableClientState glDisableClientState +#define qglDrawArrays glDrawArrays +#define qglDrawElements glDrawElements +#define qglEnable glEnable +#define qglEnableClientState glEnableClientState +#define qglFinish glFinish +#define qglFlush glFlush +#define qglFogf glFogf +#define qglFogfv glFogfv +#define qglFrontFace glFrontFace +#define qglFrustum glFrustum +#define qglGenTextures glGenTextures +#define qglGetError glGetError +#define qglGetFloatv glGetFloatv +#define qglGetIntegerv glGetIntegerv +#define qglGetString glGetString +#define qglHint glHint +#define qglIsEnabled glIsEnabled +#define qglIsTexture glIsTexture +#define qglLightModelf glLightModelf +#define qglLightModelfv glLightModelfv +#define qglLightf glLightf +#define qglLightfv glLightfv +#define qglLineWidth glLineWidth +#define qglLoadIdentity glLoadIdentity +#define qglLoadMatrixf glLoadMatrixf +#define qglLogicOp glLogicOp +#define qglMaterialf glMaterialf +#define qglMaterialfv glMaterialfv +#define qglMatrixMode glMatrixMode +#define qglMultMatrixf glMultMatrixf +#define qglNormal3f glNormal3f +#define qglNormal3fv glNormal3fv +#define qglNormalPointer glNormalPointer +#define qglOrtho glOrtho +#define qglPixelStorei glPixelStorei +#define qglPointSize glPointSize +#define qglPolygonMode glPolygonMode +#define qglPolygonOffset glPolygonOffset +#define qglPopMatrix glPopMatrix +#define qglPushMatrix glPushMatrix +#define qglReadPixels glReadPixels +#define qglRotatef glRotatef +#define qglScalef glScalef +#define qglScissor glScissor +#define qglShadeModel glShadeModel +#define qglStencilFunc glStencilFunc +#define qglStencilMask glStencilMask +#define qglStencilOp glStencilOp +#define qglTexCoordPointer glTexCoordPointer +#define qglTexEnvf glTexEnvf +#define qglTexEnvfv glTexEnvfv +#define qglTexImage2D glTexImage2D +#define qglTexParameterf glTexParameterf +#define qglTexParameterfv glTexParameterfv +#define qglTexSubImage2D glTexSubImage2D +#define qglTranslatef glTranslatef +#define qglVertexPointer glVertexPointer +#define qglViewport glViewport + +// GL_ARB_fragment_program +extern PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB; +extern PFNGLBINDPROGRAMARBPROC qglBindProgramARB; +extern PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB; +extern PFNGLGENPROGRAMSARBPROC qglGenProgramsARB; +extern PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB; +extern PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB; + +// GL_ARB_multitexture +extern PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB; +extern PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB; + +// GL_ARB_vertex_buffer_object +extern PFNGLBINDBUFFERARBPROC qglBindBufferARB; +extern PFNGLDELETEBUFFERSARBPROC qglDeleteBuffersARB; +extern PFNGLGENBUFFERSARBPROC qglGenBuffersARB; +extern PFNGLBUFFERDATAARBPROC qglBufferDataARB; +extern PFNGLBUFFERSUBDATAARBPROC qglBufferSubDataARB; + +// GL_EXT_compiled_vertex_array +extern PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT; +extern PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT; + +// ========================================================== + +#define QGL_ARB_fragment_program (1 << 0) +#define QGL_ARB_multitexture (1 << 1) +#define QGL_ARB_vertex_buffer_object (1 << 2) +#define QGL_EXT_compiled_vertex_array (1 << 3) +#define QGL_EXT_texture_filter_anisotropic (1 << 4) + +#define QGL_Init() qtrue +#define QGL_Shutdown() QGL_ShutdownExtensions(~0) + +void QGL_InitExtensions(unsigned mask); +void QGL_ShutdownExtensions(unsigned mask); + +unsigned QGL_ParseExtensionString(const char *s); + +#ifdef _DEBUG +#define QGL_EnableLogging(mask) (void)0 +#define QGL_DisableLogging(mask) (void)0 +#define QGL_LogComment(...) (void)0 +#endif + +#endif // QGL_H diff --git a/src/unix/sdl/glimp.c b/src/unix/sdl/glimp.c index 211f07b..5350b51 100644 --- a/src/unix/sdl/glimp.c +++ b/src/unix/sdl/glimp.c @@ -18,10 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "video.h" -#if USE_X11 -void VID_GLX_SurfaceChanged(void); -#endif - void VID_SDL_SurfaceChanged(void) { int accel; @@ -43,7 +39,6 @@ qboolean VID_Init(void) cvar_t *gl_depthbits; cvar_t *gl_stencilbits; cvar_t *gl_multisamples; - char *s; int colorbits; int depthbits; int stencilbits; @@ -53,16 +48,18 @@ qboolean VID_Init(void) return qfalse; } +#if USE_FIXED_LIBGL + gl_driver = Cvar_Get("gl_driver", LIBGL, CVAR_ROM); + (void)gl_driver; +#else gl_driver = Cvar_Get("gl_driver", LIBGL, CVAR_REFRESH); - gl_colorbits = Cvar_Get("gl_colorbits", "0", CVAR_REFRESH); - gl_depthbits = Cvar_Get("gl_depthbits", "0", CVAR_REFRESH); - gl_stencilbits = Cvar_Get("gl_stencilbits", "8", CVAR_REFRESH); - gl_multisamples = Cvar_Get("gl_multisamples", "0", CVAR_REFRESH); // don't allow absolute or relative paths FS_SanitizeFilenameVariable(gl_driver); while (1) { + char *s; + // ugly hack to work around brain-dead servers that actively // check and enforce `gl_driver' cvar to `opengl32', unaware // of other systems than Windows @@ -86,6 +83,12 @@ qboolean VID_Init(void) Com_Printf("...falling back to %s\n", gl_driver->default_string); Cvar_Reset(gl_driver); } +#endif + + gl_colorbits = Cvar_Get("gl_colorbits", "0", CVAR_REFRESH); + gl_depthbits = Cvar_Get("gl_depthbits", "0", CVAR_REFRESH); + gl_stencilbits = Cvar_Get("gl_stencilbits", "8", CVAR_REFRESH); + gl_multisamples = Cvar_Get("gl_multisamples", "0", CVAR_REFRESH); colorbits = Cvar_ClampInteger(gl_colorbits, 0, 32); depthbits = Cvar_ClampInteger(gl_depthbits, 0, 32); @@ -156,15 +159,27 @@ void VID_EndFrame(void) { SDL_GL_SwapBuffers(); } -#endif +#endif // !USE_X11 + +#if !USE_FIXED_LIBGL void *VID_GetCoreAddr(const char *sym) { - return SDL_GL_GetProcAddress(sym); + void *entry = SDL_GL_GetProcAddress(sym); + + if (!entry) + Com_EPrintf("Couldn't get OpenGL entry point: %s\n", sym); + + return entry; } +#endif void *VID_GetProcAddr(const char *sym) { - return SDL_GL_GetProcAddress(sym); -} + void *entry = SDL_GL_GetProcAddress(sym); + if (!entry) + Com_EPrintf("Couldn't get OpenGL entry point: %s\n", sym); + + return entry; +} diff --git a/src/unix/sdl/video.h b/src/unix/sdl/video.h index f86dc4a..20d7173 100644 --- a/src/unix/sdl/video.h +++ b/src/unix/sdl/video.h @@ -46,3 +46,7 @@ qboolean VID_SDL_Init(void); void VID_SDL_Shutdown(void); qboolean VID_SDL_SetMode(int flags, int forcedepth); void VID_SDL_SurfaceChanged(void); + +#if USE_X11 +void VID_GLX_SurfaceChanged(void); +#endif diff --git a/src/unix/system.c b/src/unix/system.c index 68e685f..24642a2 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -275,6 +275,7 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle) *handle = NULL; + dlerror(); module = dlopen(path, RTLD_LAZY); if (!module) { Com_SetLastError(dlerror()); @@ -299,7 +300,14 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle) void *Sys_GetProcAddress(void *handle, const char *sym) { - return dlsym(handle, sym); + void *entry; + + dlerror(); + entry = dlsym(handle, sym); + if (!entry) + Com_SetLastError(dlerror()); + + return entry; } /* diff --git a/src/windows/glimp.c b/src/windows/glimp.c index 4383c4e..2dead68 100644 --- a/src/windows/glimp.c +++ b/src/windows/glimp.c @@ -542,17 +542,31 @@ void VID_EndFrame(void) void *VID_GetCoreAddr(const char *sym) { + void *entry; + if (glw.hinstOpenGL) - return (void *)GetProcAddress(glw.hinstOpenGL, sym); + entry = (void *)GetProcAddress(glw.hinstOpenGL, sym); + else + entry = NULL; + + if (!entry) + Com_EPrintf("Couldn't get OpenGL entry point: %s\n", sym); - return NULL; + return entry; } void *VID_GetProcAddr(const char *sym) { + void *entry; + if (qwglGetProcAddress) - return (void *)qwglGetProcAddress(sym); + entry = (void *)qwglGetProcAddress(sym); + else + entry = NULL; + + if (!entry) + Com_EPrintf("Couldn't get OpenGL entry point: %s\n", sym); - return NULL; + return entry; } diff --git a/src/windows/system.c b/src/windows/system.c index fa8a158..8dae728 100644 --- a/src/windows/system.c +++ b/src/windows/system.c @@ -760,7 +760,7 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle) module = LoadLibraryA(path); if (!module) { - Com_SetLastError(va("%s: LoadLibrary failed with error %lu\n", + Com_SetLastError(va("%s: LoadLibrary failed with error %lu", path, GetLastError())); return NULL; } @@ -768,8 +768,8 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle) if (sym) { entry = GetProcAddress(module, sym); if (!entry) { - Com_SetLastError(va("%s: GetProcAddress failed with error %lu\n", - path, GetLastError())); + Com_SetLastError(va("%s: GetProcAddress(%s) failed with error %lu", + path, sym, GetLastError())); FreeLibrary(module); return NULL; } @@ -783,7 +783,14 @@ void *Sys_LoadLibrary(const char *path, const char *sym, void **handle) void *Sys_GetProcAddress(void *handle, const char *sym) { - return GetProcAddress(handle, sym); + void *entry; + + entry = GetProcAddress(handle, sym); + if (!entry) + Com_SetLastError(va("GetProcAddress(%s) failed with error %lu", + sym, GetLastError())); + + return entry; } /* |