mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Split up the vid plugin init sequence.
This gets gl so it no longer segs. However, the screen remains black (expect for cshifts).
This commit is contained in:
parent
6ff658afe4
commit
898bfa5e5f
7 changed files with 170 additions and 107 deletions
|
@ -70,9 +70,11 @@ typedef struct {
|
|||
void (*do_screen_buffer)(void);
|
||||
void (*set_palette)(const byte *palette);
|
||||
|
||||
// gl stuff
|
||||
void (*load_gl)(void);
|
||||
void (*init_gl)(void);
|
||||
void *(*get_proc_address)(const char *name, qboolean crit);
|
||||
void (*end_rendering)(void);
|
||||
void *(*load_library)(void);
|
||||
void *(*get_proc_address)(void *handle, const char *name);
|
||||
} viddef_t;
|
||||
|
||||
extern viddef_t viddef;
|
||||
|
|
|
@ -140,6 +140,7 @@ gl_R_LoadSky_f (void)
|
|||
void
|
||||
gl_R_Init (void)
|
||||
{
|
||||
vid = *vr_data.vid;
|
||||
R_Init_Cvars ();
|
||||
gl_R_Particles_Init_Cvars ();
|
||||
|
||||
|
|
|
@ -64,33 +64,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
|||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
||||
void *
|
||||
QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
|
||||
{
|
||||
void *glfunc = NULL;
|
||||
|
||||
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
|
||||
|
||||
glfunc = vr_data.vid->get_proc_address (handle, name);
|
||||
if (glfunc) {
|
||||
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
|
||||
return glfunc;
|
||||
}
|
||||
Sys_MaskPrintf (SYS_VID, "not found\n");
|
||||
|
||||
if (crit) {
|
||||
if (strncmp ("fxMesa", name, 6) == 0) {
|
||||
Sys_Printf ("This target requires a special version of Mesa with "
|
||||
"support for Glide and SVGAlib.\n");
|
||||
Sys_Printf ("If you are in X, try using 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_WANT(ret, name, args) \
|
||||
ret (GLAPIENTRY * qf##name) args;
|
||||
|
@ -99,23 +72,14 @@ QFGL_ProcAddress (void *handle, const char *name, qboolean crit)
|
|||
#include "QF/GL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
static void *libgl_handle;
|
||||
|
||||
// Then we need to open the libGL and set all the symbols.
|
||||
qboolean
|
||||
GLF_Init (void)
|
||||
{
|
||||
libgl_handle = vr_data.vid->load_library ();
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean
|
||||
GLF_FindFunctions (void)
|
||||
{
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
qf##name = QFGL_ProcAddress (libgl_handle, #name, false);
|
||||
qf##name = vid.get_proc_address (#name, false);
|
||||
#define QFGL_NEED(ret, name, args) \
|
||||
qf##name = QFGL_ProcAddress (libgl_handle, #name, true);
|
||||
qf##name = vid.get_proc_address (#name, true);
|
||||
#include "QF/GL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
|
@ -172,27 +136,7 @@ QFGL_ExtensionPresent (const char *name)
|
|||
void *
|
||||
QFGL_ExtensionAddress (const char *name)
|
||||
{
|
||||
static void *handle;
|
||||
|
||||
if (!handle) {
|
||||
#if defined(HAVE_DLOPEN)
|
||||
if (!(handle = dlopen (gl_driver->string, RTLD_NOW))) {
|
||||
Sys_Error ("Couldn't load OpenGL library %s: %s",
|
||||
gl_driver->string, dlerror ());
|
||||
return 0;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
if (!(handle = LoadLibrary (gl_driver->string))) {
|
||||
Sys_Error ("Couldn't load OpenGL library %s!",
|
||||
gl_driver->string);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
# error "Cannot load libraries: %s was not configured with DSO support"
|
||||
#endif
|
||||
}
|
||||
|
||||
if (name)
|
||||
return QFGL_ProcAddress (handle, name, false);
|
||||
return vid.get_proc_address (name, false);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -366,8 +366,6 @@ GL_Common_Init_Cvars (void)
|
|||
gl_lerp_anim = Cvar_Get ("gl_lerp_anim", "1", CVAR_ARCHIVE, NULL,
|
||||
"Toggles model animation interpolation");
|
||||
|
||||
gl_driver = Cvar_Get ("gl_driver", GL_DRIVER, CVAR_ROM, NULL,
|
||||
"The OpenGL library to use. (path optional)");
|
||||
gl_lightmap_align = Cvar_Get ("gl_lightmap_align", "1", CVAR_NONE, NULL,
|
||||
"Workaround for nvidia slow path. Set to 4 "
|
||||
"or 16 if you have an nvidia 3d "
|
||||
|
|
|
@ -64,33 +64,6 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
|
||||
#include "r_internal.h"
|
||||
|
||||
|
||||
void *
|
||||
QFEGL_ProcAddress (void *handle, const char *name, qboolean crit)
|
||||
{
|
||||
void *glfunc = NULL;
|
||||
|
||||
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
|
||||
|
||||
glfunc = vr_data.vid->get_proc_address (handle, name);
|
||||
if (glfunc) {
|
||||
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
|
||||
return glfunc;
|
||||
}
|
||||
Sys_MaskPrintf (SYS_VID, "not found\n");
|
||||
|
||||
if (crit) {
|
||||
if (strncmp ("fxMesa", name, 6) == 0) {
|
||||
Sys_Printf ("This target requires a special version of Mesa with "
|
||||
"support for Glide and SVGAlib.\n");
|
||||
Sys_Printf ("If you are in X, try using 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_WANT(ret, name, args) \
|
||||
ret (GLAPIENTRY * qfe##name) args;
|
||||
|
@ -99,23 +72,14 @@ QFEGL_ProcAddress (void *handle, const char *name, qboolean crit)
|
|||
#include "QF/GLSL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
static void *libgl_handle;
|
||||
|
||||
// Then we need to open the libGL and set all the symbols.
|
||||
qboolean
|
||||
EGLF_Init (void)
|
||||
{
|
||||
libgl_handle = vr_data.vid->load_library ();
|
||||
return true;
|
||||
}
|
||||
|
||||
qboolean
|
||||
EGLF_FindFunctions (void)
|
||||
{
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
qfe##name = QFEGL_ProcAddress (libgl_handle, #name, false);
|
||||
qfe##name = vid.get_proc_address (#name, false);
|
||||
#define QFGL_NEED(ret, name, args) \
|
||||
qfe##name = QFEGL_ProcAddress (libgl_handle, #name, true);
|
||||
qfe##name = vid.get_proc_address (#name, true);
|
||||
#include "QF/GLSL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include "QF/plugin/general.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "QF/GL/qf_vid.h"
|
||||
|
||||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
|
||||
|
@ -116,6 +118,8 @@ vid_render_funcs_t gl_vid_render_funcs = {
|
|||
static void
|
||||
gl_vid_render_init (void)
|
||||
{
|
||||
vr_data.vid->init_gl = GL_Init_Common;
|
||||
vr_data.vid->load_gl ();
|
||||
m_funcs = &model_funcs;
|
||||
vid = *vr_data.vid;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] =
|
||||
"$Id$";
|
||||
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
|
@ -48,6 +47,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
@ -105,6 +105,152 @@ static int shiftmask_fl = 0;
|
|||
static long r_shift, g_shift, b_shift;
|
||||
static unsigned long r_mask, g_mask, b_mask;
|
||||
|
||||
#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
|
||||
|
||||
// GLXContext is a pointer to opaque data
|
||||
typedef struct __GLXcontextRec *GLXContext;
|
||||
typedef XID GLXDrawable;
|
||||
|
||||
// Define GLAPIENTRY to a useful value
|
||||
#ifndef GLAPIENTRY
|
||||
# ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define GLAPIENTRY WINAPI
|
||||
# undef LoadImage
|
||||
# else
|
||||
# ifdef APIENTRY
|
||||
# define GLAPIENTRY APIENTRY
|
||||
# else
|
||||
# define GLAPIENTRY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
static GLXContext ctx = NULL;
|
||||
static void *libgl_handle;
|
||||
static void (*qfglXSwapBuffers) (Display *dpy, GLXDrawable drawable);
|
||||
static XVisualInfo* (*qfglXChooseVisual) (Display *dpy, int screen,
|
||||
int *attribList);
|
||||
static GLXContext (*qfglXCreateContext) (Display *dpy, XVisualInfo *vis,
|
||||
GLXContext shareList, Bool direct);
|
||||
static Bool (*qfglXMakeCurrent) (Display *dpy, GLXDrawable drawable,
|
||||
GLXContext ctx);
|
||||
static void (GLAPIENTRY *qfglFinish) (void);
|
||||
static void *(*glGetProcAddress) (const char *symbol) = NULL;
|
||||
static int use_gl_procaddress = 0;
|
||||
static cvar_t *gl_driver;
|
||||
|
||||
static void (*choose_visual) (void);
|
||||
static void (*create_context) (void);
|
||||
|
||||
static void *
|
||||
QFGL_GetProcAddress (void *handle, const char *name)
|
||||
{
|
||||
void *glfunc = NULL;
|
||||
|
||||
if (use_gl_procaddress && glGetProcAddress)
|
||||
glfunc = glGetProcAddress (name);
|
||||
if (!glfunc)
|
||||
glfunc = dlsym (handle, name);
|
||||
return glfunc;
|
||||
}
|
||||
|
||||
static void *
|
||||
QFGL_ProcAddress (const char *name, qboolean crit)
|
||||
{
|
||||
void *glfunc = NULL;
|
||||
|
||||
Sys_MaskPrintf (SYS_VID, "DEBUG: Finding symbol %s ... ", name);
|
||||
|
||||
glfunc = QFGL_GetProcAddress (libgl_handle, name);
|
||||
if (glfunc) {
|
||||
Sys_MaskPrintf (SYS_VID, "found [%p]\n", glfunc);
|
||||
return glfunc;
|
||||
}
|
||||
Sys_MaskPrintf (SYS_VID, "not found\n");
|
||||
|
||||
if (crit) {
|
||||
if (strncmp ("fxMesa", name, 6) == 0) {
|
||||
Sys_Printf ("This target requires a special version of Mesa with "
|
||||
"support for Glide and SVGAlib.\n");
|
||||
Sys_Printf ("If you are in X, try using a GLX or SGL target.\n");
|
||||
}
|
||||
Sys_Error ("Couldn't load critical OpenGL function %s, exiting...",
|
||||
name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
glx_choose_visual (void)
|
||||
{
|
||||
int attrib[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
None
|
||||
};
|
||||
|
||||
x_visinfo = qfglXChooseVisual (x_disp, x_screen, attrib);
|
||||
if (!x_visinfo) {
|
||||
Sys_Error ("Error couldn't get an RGB, Double-buffered, Depth visual");
|
||||
}
|
||||
x_vis = x_visinfo->visual;
|
||||
}
|
||||
|
||||
static void
|
||||
glx_create_context (void)
|
||||
{
|
||||
XSync (x_disp, 0);
|
||||
ctx = qfglXCreateContext (x_disp, x_visinfo, NULL, True);
|
||||
qfglXMakeCurrent (x_disp, x_win, ctx);
|
||||
viddef.init_gl ();
|
||||
}
|
||||
|
||||
static void
|
||||
glx_end_rendering (void)
|
||||
{
|
||||
qfglFinish ();
|
||||
qfglXSwapBuffers (x_disp, x_win);
|
||||
}
|
||||
|
||||
static void
|
||||
glx_load_gl (void)
|
||||
{
|
||||
int flags = RTLD_NOW;
|
||||
|
||||
choose_visual = glx_choose_visual;
|
||||
create_context = glx_create_context;
|
||||
|
||||
viddef.get_proc_address = QFGL_ProcAddress;
|
||||
viddef.end_rendering = glx_end_rendering;
|
||||
|
||||
#ifdef RTLD_GLOBAL
|
||||
flags |= RTLD_GLOBAL;
|
||||
#endif
|
||||
if (!(libgl_handle = dlopen (gl_driver->string, flags))) {
|
||||
Sys_Error ("Couldn't load OpenGL library %s: %s", gl_driver->string,
|
||||
dlerror ());
|
||||
}
|
||||
glGetProcAddress = dlsym (libgl_handle, "glXGetProcAddress");
|
||||
if (!glGetProcAddress)
|
||||
glGetProcAddress = dlsym (libgl_handle, "glXGetProcAddressARB");
|
||||
|
||||
qfglXSwapBuffers = QFGL_ProcAddress ("glXSwapBuffers", true);
|
||||
qfglXChooseVisual = QFGL_ProcAddress ("glXChooseVisual", true);
|
||||
qfglXCreateContext = QFGL_ProcAddress ("glXCreateContext", true);
|
||||
qfglXMakeCurrent = QFGL_ProcAddress ("glXMakeCurrent", true);
|
||||
qfglFinish = QFGL_ProcAddress ("glFinish", true);
|
||||
|
||||
use_gl_procaddress = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
shiftmask_init (void)
|
||||
|
@ -488,8 +634,6 @@ x11_create_context (void)
|
|||
}
|
||||
|
||||
/*
|
||||
VID_Init
|
||||
|
||||
Set up color translation tables and the window. Takes a 256-color 8-bit
|
||||
palette. Palette data will go away after the call, so copy it if you'll
|
||||
need it later.
|
||||
|
@ -497,6 +641,10 @@ x11_create_context (void)
|
|||
void
|
||||
VID_Init (byte *palette, byte *colormap)
|
||||
{
|
||||
choose_visual = x11_choose_visual;
|
||||
create_context = x11_create_context;
|
||||
viddef.load_gl = glx_load_gl;
|
||||
|
||||
R_LoadModule ();
|
||||
|
||||
viddef.numpages = 2;
|
||||
|
@ -507,11 +655,11 @@ VID_Init (byte *palette, byte *colormap)
|
|||
|
||||
VID_GetWindowSize (320, 200);
|
||||
X11_OpenDisplay ();
|
||||
x11_choose_visual ();
|
||||
choose_visual ();
|
||||
X11_SetVidMode (viddef.width, viddef.height);
|
||||
X11_CreateWindow (viddef.width, viddef.height);
|
||||
X11_CreateNullCursor (); // hide mouse pointer
|
||||
x11_create_context ();
|
||||
create_context ();
|
||||
|
||||
VID_InitGamma (palette);
|
||||
VID_SetPalette (viddef.palette);
|
||||
|
@ -527,6 +675,8 @@ void
|
|||
VID_Init_Cvars ()
|
||||
{
|
||||
X11_Init_Cvars ();
|
||||
gl_driver = Cvar_Get ("gl_driver", GL_DRIVER, CVAR_ROM, NULL,
|
||||
"The OpenGL library to use. (path optional)");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue