Move the contents of gl_funcs.c out of the renderer, and into targets where they belong. Also some cleanups. -sgl target is temporarily broken, all others should work.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2002-06-24 21:35:37 +00:00
parent 70d8026067
commit e6e11af426
8 changed files with 215 additions and 214 deletions

View file

@ -46,4 +46,8 @@ extern void *libgl_handle;
qboolean GLF_Init (void);
void *QFGL_ProcAddress (void *, const char *, qboolean);
extern void *(*glGetProcAddress) (const char *);
extern void *(*getProcAddress) (void *, const char *);
extern void *QFGL_LoadLibrary (void);
#endif // __QF_GL_funcs_h_

View file

@ -9,10 +9,10 @@ noinst_LTLIBRARIES=
endif
gl_src = \
gl_draw.c gl_dyn_lights.c \
gl_dyn_part.c gl_dyn_textures.c gl_graph.c gl_mod_alias.c gl_mod_sprite.c \
gl_draw.c gl_dyn_lights.c gl_dyn_part.c gl_dyn_textures.c \
gl_graph.c gl_mod_alias.c gl_mod_sprite.c \
gl_rmain.c gl_rmisc.c gl_rsurf.c gl_screen.c gl_skin.c gl_sky.c \
gl_sky_clip.c gl_textures.c gl_warp.c gl_funcs.c noisetextures.c
gl_sky_clip.c gl_textures.c gl_warp.c noisetextures.c
libgl_la_SOURCES= $(gl_src)

View file

@ -1,160 +0,0 @@
/*
gl_funcs.c
GL functions.
Copyright (C) 1996-1997 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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdio.h>
#include <QF/cvar.h>
#include <QF/console.h>
#include <QF/sys.h>
#include <QF/GL/funcs.h>
#include "r_cvar.h"
// First we need to get all the function pointers declared.
#define QFGL_NEED(ret, name, args) \
ret (GLAPIENTRY * qf##name) args;
#include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED
void *libgl_handle;
#if defined(HAVE_DLOPEN)
static QF_glXGetProcAddressARB glGetProcAddress = NULL;
static void * (*getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
void *handle;
if (!(handle = dlopen (gl_driver->string, RTLD_NOW))) {
Sys_Error ("Couldn't load OpenGL library %s: %s", gl_driver->string,
dlerror ());
}
getProcAddress = dlsym;
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
return handle;
}
#elif defined(_WIN32)
static void * (APIENTRY *glGetProcAddress) (const char *) = NULL;
static FARPROC (WINAPI *getProcAddress) (HINSTANCE,LPCSTR);
void *
QFGL_LoadLibrary (void)
{
void *handle;
if (!(handle = LoadLibrary (gl_driver->string))) {
Sys_Error ("Couldn't load OpenGL library %s!", gl_driver->string);
}
getProcAddress = GetProcAddress;
(FARPROC)glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress");
return handle;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
static QF_glXGetProcAddressARB glGetProcAddress = NULL;
static void * (*getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
return 0;
}
#endif
// Then we need to open the libGL and set all the symbols.
qboolean
GLF_Init (void)
{
libgl_handle = QFGL_LoadLibrary ();
#define QFGL_NEED(ret, name, args) \
qf##name = QFGL_ProcAddress (libgl_handle, #name, true);
#include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED
return true;
}
void *
QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
{
void *glfunc = NULL;
Con_DPrintf ("DEBUG: Finding symbol %s ... ", name);
if (glGetProcAddress)
glfunc = glGetProcAddress (name);
if (!glfunc)
glfunc = getProcAddress (handle, name);
if (glfunc) {
Con_DPrintf ("found [%p]\n", glfunc);
return glfunc;
}
Con_DPrintf ("not found\n");
if (crit) {
if (strncmp("fxMesa", name,6) == 0) {
Con_DPrintf ("This is a console only client. It requires a mesa-glide compatable library\n");
Con_DPrintf ("If you are trying to run QuakeForge in X, please use -glx clients\n");
}
Sys_Error ("Couldn't load critical OpenGL function %s, exiting...", name);
}
return NULL;
}

View file

@ -56,6 +56,7 @@ static const char rcsid[] =
# include <strings.h>
#endif
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/qtypes.h"
#include "QF/sys.h"
@ -65,6 +66,57 @@ static const char rcsid[] =
#include "r_cvar.h"
void *
QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
{
void *glfunc = NULL;
Con_DPrintf ("DEBUG: Finding symbol %s ... ", name);
if (glGetProcAddress)
glfunc = glGetProcAddress (name);
if (!glfunc)
glfunc = getProcAddress (handle, name);
if (glfunc) {
Con_DPrintf ("found [%p]\n", glfunc);
return glfunc;
}
Con_DPrintf ("not found\n");
if (crit) {
if (strncmp ("fxMesa", name, 6) == 0) {
Con_DPrintf ("This is a console-only client. It requires a "
"mesa-glide compatable library.\n");
Con_DPrintf ("If you are trying to run OpenGL QuakeForge in X, "
"please use a -glx or -sgl target.\n");
}
Sys_Error ("Couldn't load critical OpenGL function %s, exiting...",
name);
}
return NULL;
}
// First we need to get all the function pointers declared.
#define QFGL_NEED(ret, name, args) \
ret (GLAPIENTRY * qf##name) args;
#include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED
void *libgl_handle;
// Then we need to open the libGL and set all the symbols.
qboolean
GLF_Init (void)
{
libgl_handle = QFGL_LoadLibrary ();
#define QFGL_NEED(ret, name, args) \
qf##name = QFGL_ProcAddress (libgl_handle, #name, true);
#include "QF/GL/qf_funcs_list.h"
#undef QFGL_NEED
return true;
}
/*
ParseExtensionList

View file

@ -59,43 +59,43 @@ static const char rcsid[] =
#include "sbar.h"
#include "r_cvar.h"
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
#define GLAPI extern
#define GLAPIENTRY
#define FXMESA_NONE 0 /* to terminate attribList */
#define FXMESA_NONE 0 // to terminate attribList
#define FXMESA_DOUBLEBUFFER 10
#define FXMESA_ALPHA_SIZE 11 /* followed by an integer */
#define FXMESA_DEPTH_SIZE 12 /* followed by an integer */
#define FXMESA_ALPHA_SIZE 11 // followed by an integer
#define FXMESA_DEPTH_SIZE 12 // followed by an integer
#define GL_DITHER 0x0BD0
#define GL_DITHER 0x0BD0
typedef struct tfxMesaContext *fxMesaContext;
typedef long FxI32;
typedef FxI32 GrScreenResolution_t;
typedef FxI32 GrDitherMode_t;
typedef FxI32 GrScreenRefresh_t;
typedef FxI32 GrScreenResolution_t;
typedef FxI32 GrDitherMode_t;
typedef FxI32 GrScreenRefresh_t;
#define GR_REFRESH_75Hz 0x3
#define GR_REFRESH_75Hz 0x3
#define GR_DITHER_2x2 0x1
#define GR_DITHER_4x4 0x2
#define GR_RESOLUTION_320x200 0x0
#define GR_RESOLUTION_320x240 0x1
#define GR_RESOLUTION_400x256 0x2
#define GR_RESOLUTION_512x384 0x3
#define GR_RESOLUTION_640x200 0x4
#define GR_RESOLUTION_640x350 0x5
#define GR_RESOLUTION_640x400 0x6
#define GR_RESOLUTION_640x480 0x7
#define GR_RESOLUTION_800x600 0x8
#define GR_RESOLUTION_960x720 0x9
#define GR_RESOLUTION_512x256 0xb
#define GR_RESOLUTION_856x480 0xa
#define GR_RESOLUTION_400x300 0xF
#define GR_DITHER_2x2 0x1
#define GR_DITHER_4x4 0x2
#define GR_RESOLUTION_320x200 0x0
#define GR_RESOLUTION_320x240 0x1
#define GR_RESOLUTION_400x256 0x2
#define GR_RESOLUTION_512x384 0x3
#define GR_RESOLUTION_640x200 0x4
#define GR_RESOLUTION_640x350 0x5
#define GR_RESOLUTION_640x400 0x6
#define GR_RESOLUTION_640x480 0x7
#define GR_RESOLUTION_800x600 0x8
#define GR_RESOLUTION_960x720 0x9
#define GR_RESOLUTION_512x256 0xb
#define GR_RESOLUTION_856x480 0xa
#define GR_RESOLUTION_400x300 0xF
void (* qf_fxMesaDestroyContext) (fxMesaContext ctx);
void (* qf_fxMesaSwapBuffers) (void);
@ -105,12 +105,43 @@ void (* qf_fxMesaMakeCurrent) (fxMesaContext ctx);
// FIXME!!!!! This belongs in include/qfgl_ext.h -- deek
typedef void (GLAPIENTRY * QF_3DfxSetDitherModeEXT) (GrDitherMode_t mode);
static fxMesaContext fc = NULL;
int VID_options_items = 0;
int VID_options_items = 0;
#if defined(HAVE_DLOPEN)
void * (* glGetProcAddress) (const char *symbol)= NULL;
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
void *handle;
if (!(handle = dlopen (gl_driver->string, RTLD_NOW))) {
Sys_Error ("Couldn't load OpenGL library %s: %s", gl_driver->string,
dlerror ());
}
getProcAddress = dlsym;
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
return handle;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
return 0;
}
#endif // HAVE_DLOPEN
void
VID_Shutdown (void)

View file

@ -71,25 +71,58 @@ static const char rcsid[] =
/* GLXContext is a pointer to opaque data. */
typedef struct __GLXcontextRec *GLXContext;
#define GLX_RGBA 4 /* true if RGBA mode */
#define GLX_DOUBLEBUFFER 5 /* double buffering supported */
#define GLX_RED_SIZE 8 /* number of red component bits */
#define GLX_GREEN_SIZE 9 /* number of green component bits */
#define GLX_BLUE_SIZE 10 /* number of blue component bits */
#define GLX_DEPTH_SIZE 12 /* number of depth bits */
#define GLX_RGBA 4 // true if RGBA mode
#define GLX_DOUBLEBUFFER 5 // double buffering supported
#define GLX_RED_SIZE 8 // number of red component bits
#define GLX_GREEN_SIZE 9 // number of green component bits
#define GLX_BLUE_SIZE 10 // number of blue component bits
#define GLX_DEPTH_SIZE 12 // number of depth bits
static GLXContext ctx = NULL;
typedef XID GLXDrawable;
void (* qfglXSwapBuffers) (Display *dpy, GLXDrawable drawable);
XVisualInfo* (* qfglXChooseVisual) (Display *dpy, int screen, int *attribList);
GLXContext (* qfglXCreateContext) (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
GLXContext (* qfglXCreateContext) (Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool direct);
Bool (* qfglXMakeCurrent) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
/*-----------------------------------------------------------------------*/
#if defined(HAVE_DLOPEN)
void * (* glGetProcAddress) (const char *symbol) = NULL;
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
void *handle;
if (!(handle = dlopen (gl_driver->string, RTLD_NOW))) {
Sys_Error ("Couldn't load OpenGL library %s: %s", gl_driver->string,
dlerror ());
}
getProcAddress = dlsym;
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
return handle;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
return 0;
}
#endif // HAVE_DLOPEN
void
VID_Shutdown (void)

View file

@ -65,11 +65,24 @@ HWND mainwindow;
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
int VID_options_items = 1;
int modestate;
int VID_options_items = 1;
int modestate;
static SDL_Surface *screen = NULL;
void * (* glGetProcAddress) (const char *symbol) = NULL; // FIXME
//# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
return 0;
}
//#endif
void
VID_SDL_GammaCheck (void)

View file

@ -93,28 +93,27 @@ typedef struct {
int height;
} lmode_t;
lmode_t lowresmodes[] = {
lmode_t lowresmodes[] = {
{320, 200},
{320, 240},
{400, 300},
{512, 384},
};
// FIXME: Only used by MGL ..
qboolean DDActive;
qboolean DDActive;
// If you ever merge screen/gl_screen, don't forget this one
qboolean scr_skipupdate;
qboolean scr_skipupdate;
static vmode_t modelist[MAX_MODE_LIST];
static int nummodes;
static vmode_t badmode;
static int nummodes;
static vmode_t modelist[MAX_MODE_LIST];
static vmode_t badmode;
DEVMODE win_gdevmode;
DEVMODE win_gdevmode;
qboolean win_canalttab = false;
static qboolean windowed, leavecurrentmode;
static int windowed_mouse;
static qboolean windowed, leavecurrentmode;
static int windowed_mouse;
static HICON hIcon;
RECT WindowRect;
@ -134,8 +133,6 @@ HDC maindc;
HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
LONG CDAudio_MessageHandler (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
modestate_t modestate = MS_UNINIT;
LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -144,12 +141,43 @@ char *VID_GetModeDescription (int mode);
void VID_UpdateWindowStatus (int window_x, int window_y);
void GL_Init (void);
#if defined(_WIN32)
void * (* glGetProcAddress) (const char *symbol) = NULL;
void * (* getProcAddress) (HINSTANCE, LPCSTR);
void *
QFGL_LoadLibrary (void)
{
void *handle;
if (!(handle = LoadLibrary (gl_driver->string)))
Sys_Error ("Couldn't load OpenGL library %s!", gl_driver->string);
getProcAddress = GetProcAddress;
(FARPROC)glGetProcAddress = GetProcAddress (handle, "wglGetProcAddress");
return handle;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
void * (* getProcAddress) (void *handle, const char *symbol);
void *
QFGL_LoadLibrary (void)
{
return 0;
}
#endif // _WIN32
//====================================
int window_center_x, window_center_y, window_x, window_y, window_width,
int window_center_x, window_center_y, window_x, window_y, window_width,
window_height;
RECT window_rect;
RECT window_rect;
void