qfplist.h:

remove include of glob.h. not needed and causes win32 build to fail
plugin.c:
	include compat.h and cast the return of GetProcAddress
gl_funcs.c:
	fix parse error and type mismatch
qfgl_ext.c:
	half re-write QFGL_ExtensionAddress to use QFGL_ProcAddress
vid_wgl.c:
	fix for the new gl linking
This commit is contained in:
Bill Currie 2001-07-05 17:28:19 +00:00
parent 8f2f99fae6
commit c38ca8e2f1
5 changed files with 67 additions and 48 deletions

View file

@ -29,8 +29,6 @@
#ifndef __QF_qfplist_h_
#define __QF_qfplist_h_
#include <glob.h>
#include "QF/qtypes.h"
// Ugly defines for fast checking and conversion from char to number

View file

@ -58,8 +58,10 @@
#endif
#include "QF/cvar.h"
#include <QF/plugin.h>
#include <QF/console.h>
#include "QF/plugin.h"
#include "QF/console.h"
#include "compat.h"
cvar_t *fs_pluginpath;
@ -132,7 +134,7 @@ PI_LoadPlugin (char *type, char *name)
return NULL;
}
#elif defined (_WIN32)
if (!(plugin_info = GetProcAddress (dlhand, "PluginInfo"))) { // info function not found
if (!(plugin_info = (P_PluginInfo) GetProcAddress (dlhand, "PluginInfo"))) { // info function not found
FreeLibrary (dlhand);
Con_Printf ("Plugin info function not found\n");
return NULL;

View file

@ -94,7 +94,7 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
#if defined(HAVE_DLOPEN)
static QF_glXGetProcAddressARB glGetProcAddress = NULL;
#elif defined(_WIN32)
static void * (* wglGetProcAddress) (char *) glGetProcAddress = NULL;
static void * (* glGetProcAddress) (const char *) = NULL;
#else
static void *glGetProcAddress = NULL;
#endif
@ -109,7 +109,7 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
#if defined(HAVE_DLOPEN)
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
#elif defined(_WIN32)
glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress");
(FARPROC)glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress");
#endif
}

View file

@ -60,6 +60,10 @@
#include "QF/GL/extensions.h"
#include "QF/GL/funcs.h"
#include "QF/cvar.h"
#include "QF/sys.h"
#include "r_cvar.h"
/*
ParseExtensionList
@ -108,47 +112,43 @@ QFGL_ExtensionPresent (const char *name)
void *
QFGL_ExtensionAddress (const char *name)
{
#if defined(HAVE_GLX) && defined(HAVE_DLOPEN)
void *dlhand = NULL;
void *handle;
static qboolean glProcAddress_present = true;
static QF_glXGetProcAddressARB qfglXGetProcAddress = NULL;
#if defined(HAVE_GLX)
static QF_glXGetProcAddressARB glGetProcAddress = NULL;
#else
static void * (* glGetProcAddress) (const char *) = NULL;
#endif
if (glProcAddress_present && !qfglXGetProcAddress) {
#if defined(HAVE_DLOPEN)
if (!(handle = dlopen (gl_libgl->string, RTLD_NOW))) {
Sys_Error ("Couldn't load OpenGL library %s: %s\n", gl_libgl->string, dlerror ());
return 0;
}
#elif defined(_WIN32)
if (!(handle = LoadLibrary (gl_libgl->string))) {
Sys_Error ("Couldn't load OpenGL library %s!\n", gl_libgl->string);
return 0;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
#endif
if (glProcAddress_present && !glGetProcAddress) {
if (QFGL_ExtensionPresent ("GLX_ARB_get_proc_address")) {
if ((dlhand = dlopen (NULL, RTLD_LAZY))) {
qfglXGetProcAddress = dlsym (dlhand, "glXGetProcAddressARB");
dlclose (dlhand);
} else {
#if defined(HAVE_GLX)
glGetProcAddress = QFGL_ProcAddress (handle, "glXGetProcAddressARB", false);
#elif defined (_WIN32)
glGetProcAddress = QFGL_ProcAddress (handle, "wglGetProcAddress", false);
#endif
if (!glGetProcAddress)
glProcAddress_present = false;
}
} else {
glProcAddress_present = false;
}
}
#endif
if (name) {
#if defined(HAVE_GLX) && defined(HAVE_DLOPEN)
if (glProcAddress_present) {
return qfglXGetProcAddress ((const GLubyte *) name);
} else {
if ((dlhand = dlopen (NULL, RTLD_LAZY))) {
void *handle;
handle = dlsym (dlhand, name);
dlclose (dlhand);
return handle;
}
return NULL;
}
#else
# ifdef _WIN32
return wglGetProcAddress (name);
# else
return NULL;
# endif
#endif
}
if (name && glProcAddress_present)
return glGetProcAddress (name);
return NULL;
}

View file

@ -32,6 +32,7 @@
#include "winquake.h"
#include "QF/GL/funcs.h"
#include "QF/cdaudio.h"
#include "QF/cmd.h"
#include "QF/console.h"
@ -49,8 +50,8 @@
#include "compat.h"
#include "sbar.h"
#include "glquake.h"
#include "in_win.h"
#include "r_cvar.h"
#include "resource.h"
extern void GL_Init_Common (void);
@ -59,6 +60,12 @@ extern void VID_Init8bitPalette (void);
extern void (*vid_menudrawfn) (void);
extern void (*vid_menukeyfn) (int);
HGLRC (*qf_wglCreateContext) (HDC);
BOOL (*qf_wglDeleteContext) (HGLRC);
HGLRC (*qf_wglGetCurrentContext) (void);
HDC (*qf_wglGetCurrentDC) (void);
BOOL (*qf_wglMakeCurrent) (HDC, HGLRC);
#define MAX_MODE_LIST 30
#define VID_ROW_SIZE 3
#define WARP_WIDTH 320
@ -100,6 +107,7 @@ const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;
void *libgl_handle;
// 8-bit and permedia support
qboolean isPermedia = false;
@ -517,10 +525,10 @@ VID_Shutdown (void)
if (vid.initialized) {
vid_canalttab = false;
hRC = wglGetCurrentContext ();
hDC = wglGetCurrentDC ();
hRC = qf_wglGetCurrentContext ();
hDC = qf_wglGetCurrentDC ();
wglMakeCurrent (NULL, NULL);
qf_wglMakeCurrent (NULL, NULL);
// LordHavoc: free textures before closing (may help NVIDIA)
for (i = 0; i < 8192; i++)
@ -528,7 +536,7 @@ VID_Shutdown (void)
qfglDeleteTextures (8192, temp);
if (hRC)
wglDeleteContext (hRC);
qf_wglDeleteContext (hRC);
if (hDC && mainwindow)
ReleaseDC (mainwindow, hDC);
@ -1197,6 +1205,17 @@ VID_Init (unsigned char *palette)
HGLRC baseRC;
DWORD lasterror;
if (!(libgl_handle = LoadLibrary (gl_libgl->string))) {
Sys_Error ("Can't open OpenGL library \"%s\"\n", gl_libgl->string);
return;
}
qf_wglCreateContext = QFGL_ProcAddress (libgl_handle, "wglCreateContext", true);
qf_wglDeleteContext = QFGL_ProcAddress (libgl_handle, "wglDeleteContext", true);
qf_wglGetCurrentContext = QFGL_ProcAddress (libgl_handle, "wglGetCurrentContext", true);
qf_wglGetCurrentDC = QFGL_ProcAddress (libgl_handle, "wglGetCurrentDC", true);
qf_wglMakeCurrent = QFGL_ProcAddress (libgl_handle, "wglMakeCurrent", true);
memset (&devmode, 0, sizeof (devmode));
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, "Reports the total number of video modes available");
@ -1384,7 +1403,7 @@ VID_Init (unsigned char *palette)
maindc = GetDC (mainwindow);
bSetupPixelFormat (maindc);
baseRC = wglCreateContext (maindc);
baseRC = qf_wglCreateContext (maindc);
if (!baseRC) {
lasterror=GetLastError();
if (maindc && mainwindow)
@ -1392,10 +1411,10 @@ VID_Init (unsigned char *palette)
Sys_Error("Could not initialize GL (wglCreateContext failed).\n\nMake sure you in are 65535 color mode, and try running -window. \nError code: (%lx)\r\n",lasterror);
}
if (!wglMakeCurrent (maindc, baseRC)) {
if (!qf_wglMakeCurrent (maindc, baseRC)) {
lasterror=GetLastError();
if (baseRC)
wglDeleteContext (baseRC);
qf_wglDeleteContext (baseRC);
if (maindc && mainwindow)
ReleaseDC (mainwindow, maindc);
Sys_Error ("wglMakeCurrent failed (%lx)\r\n",lasterror);