diff --git a/libs/video/targets/Makefile.am b/libs/video/targets/Makefile.am index d82cce6fc..3a79de2e9 100644 --- a/libs/video/targets/Makefile.am +++ b/libs/video/targets/Makefile.am @@ -80,9 +80,8 @@ libQFsvga.la: $(libQFsvga_la_OBJECTS) $(libQFsvga_la_DEPENDENCIES) libQFtdfx_la_LDFLAGS= -version-info 1:0:0 libQFtdfx_la_SOURCES= in_common.c in_svgalib.c qfgl_ext.c vid.c vid_common_gl.c vid_3dfxsvga.c -TDFX_LIBS = $(LIBS) -lGL libQFtdfx.la: $(libQFtdfx_la_OBJECTS) $(libQFtdfx_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libQFtdfx_la_LDFLAGS) $(libQFtdfx_la_OBJECTS) $(libQFtdfx_la_LIBADD) $(TDFX_LIBS) + $(LINK) -rpath $(libdir) $(libQFtdfx_la_LDFLAGS) $(libQFtdfx_la_OBJECTS) $(libQFtdfx_la_LIBADD) $(LIBS) libQFwgl_la_LDFLAGS= -version-info 1:0:0 diff --git a/libs/video/targets/vid_3dfxsvga.c b/libs/video/targets/vid_3dfxsvga.c index 82173b4a8..eb8be644c 100644 --- a/libs/video/targets/vid_3dfxsvga.c +++ b/libs/video/targets/vid_3dfxsvga.c @@ -42,6 +42,10 @@ #include #include +#ifdef HAVE_DLOPEN +# include +#endif + #include "compat.h" #include "QF/console.h" #include "QF/cvar.h" @@ -53,6 +57,7 @@ #include "QF/sys.h" #include "QF/va.h" #include "QF/vid.h" +#include "r_cvar.h" #define WARP_WIDTH 320 #define WARP_HEIGHT 200 @@ -69,10 +74,10 @@ typedef struct tfxMesaContext *fxMesaContext; -GLAPI void GLAPIENTRY fxMesaDestroyContext(fxMesaContext ctx); -GLAPI void GLAPIENTRY fxMesaSwapBuffers(void); -GLAPI fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]); -GLAPI void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext ctx); +void (* fxMesaDestroyContext) (fxMesaContext ctx); +void (* fxMesaSwapBuffers) (void); +fxMesaContext (* fxMesaCreateContext) (GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]); +void (* fxMesaMakeCurrent) (fxMesaContext ctx); // FIXME!!!!! This belongs in include/qfgl_ext.h -- deek typedef void (GLAPIENTRY * QF_3DfxSetDitherModeEXT) (GrDitherMode_t mode); @@ -82,6 +87,8 @@ cvar_t *tdfx_brighten; static fxMesaContext fc = NULL; +void *libgl_handle; + int VID_options_items = 0; extern void GL_Init_Common (void); @@ -262,6 +269,20 @@ VID_Init (unsigned char *palette) int i; GLint attribs[32]; +#ifdef HAVE_DLOPEN + if (!(libgl_handle = dlopen (gl_libgl->string, RTLD_NOW))) { + Sys_Error ("Can't open OpenGL library \"%s\": %s\n", gl_libgl->string, dlerror()); + return; + } +#else +# error "No dynamic library support. FIXME." +#endif + fxMesaCreateContext = QFGL_ProcAddress (libgl_handle, "fxMesaCreateContext", true); + fxMesaDestroyContext = QFGL_ProcAddress (libgl_handle, "fxMesaDestroyContext", true); + fxMesaMakeCurrent = QFGL_ProcAddress (libgl_handle, "fxMesaMakeCurrent", true); + fxMesaSwapBuffers = QFGL_ProcAddress (libgl_handle, "fxMesaSwapBuffers", true); + + QFGL_ProcAddress (NULL, NULL, false); VID_GetWindowSize (640, 480); Con_CheckResize (); // Now that we have a window size, fix console