mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 22:01:33 +00:00
Move vid callbacks into vid_internal
Currently segfaults because viddef is an alias for *r_data->vid, which has not yet been initialized (chicken and egg).
This commit is contained in:
parent
3e1520c246
commit
6ee2df8445
19 changed files with 86 additions and 64 deletions
|
@ -61,17 +61,7 @@ typedef struct {
|
|||
int conheight;
|
||||
byte *direct; // direct drawing to framebuffer, if not
|
||||
// NULL
|
||||
int (*surf_cache_size)(int width, int height);
|
||||
void (*flush_caches)(void);
|
||||
void (*init_caches)(void *cache, int size);
|
||||
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);
|
||||
struct vid_internal_s *vid_internal;
|
||||
} viddef_t;
|
||||
|
||||
#define viddef (*r_data->vid)
|
||||
|
|
|
@ -4,6 +4,20 @@
|
|||
#include "QF/vid.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
typedef struct vid_internal_s {
|
||||
int (*surf_cache_size) (int width, int height);
|
||||
void (*flush_caches) (void);
|
||||
void (*init_caches) (void *cache, int size);
|
||||
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);
|
||||
} vid_internal_t;
|
||||
|
||||
extern struct cvar_s *vid_fullscreen;
|
||||
extern struct cvar_s *vid_system_gamma;
|
||||
extern struct cvar_s *vid_gamma;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
#include "varrays.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
/*
|
||||
R_Envmap_f
|
||||
|
@ -121,7 +122,7 @@ R_Envmap_f (void)
|
|||
gl_envmap = false;
|
||||
qfglDrawBuffer (GL_BACK);
|
||||
qfglReadBuffer (GL_BACK);
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -249,13 +250,13 @@ gl_R_TimeRefresh_f (void)
|
|||
double start, stop, time;
|
||||
int i;
|
||||
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
|
||||
start = Sys_DoubleTime ();
|
||||
for (i = 0; i < 128; i++) {
|
||||
r_refdef.viewangles[1] = i * (360.0 / 128.0);
|
||||
gl_R_RenderView ();
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
}
|
||||
|
||||
stop = Sys_DoubleTime ();
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "compat.h"
|
||||
#include "r_internal.h"
|
||||
#include "sbar.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
/* SCREEN SHOTS */
|
||||
|
||||
|
@ -206,7 +207,7 @@ gl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
return;
|
||||
|
||||
if (begun)
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
|
||||
vr_data.realtime = realtime;
|
||||
|
||||
|
@ -263,7 +264,7 @@ gl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
qfglFlush ();
|
||||
|
||||
if (gl_finish->int_val) {
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
begun = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "QF/GL/funcs.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
// First we need to get all the function pointers declared.
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
|
@ -75,9 +76,9 @@ qboolean
|
|||
GLF_FindFunctions (void)
|
||||
{
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
qf##name = vid.get_proc_address (#name, false);
|
||||
qf##name = vid.vid_internal->get_proc_address (#name, false);
|
||||
#define QFGL_NEED(ret, name, args) \
|
||||
qf##name = vid.get_proc_address (#name, true);
|
||||
qf##name = vid.vid_internal->get_proc_address (#name, true);
|
||||
#include "QF/GL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
|
@ -135,6 +136,6 @@ void *
|
|||
QFGL_ExtensionAddress (const char *name)
|
||||
{
|
||||
if (name)
|
||||
return vid.get_proc_address (name, false);
|
||||
return vid.vid_internal->get_proc_address (name, false);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
mat4_t glsl_projection;
|
||||
mat4_t glsl_view;
|
||||
|
@ -304,13 +305,13 @@ glsl_R_TimeRefresh_f (void)
|
|||
double start, stop, time;
|
||||
int i;
|
||||
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
|
||||
start = Sys_DoubleTime ();
|
||||
for (i = 0; i < 128; i++) {
|
||||
r_refdef.viewangles[1] = i * (360.0 / 128.0);
|
||||
glsl_R_RenderView ();
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
}
|
||||
|
||||
stop = Sys_DoubleTime ();
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "QF/GLSL/qf_vid.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
/* Unknown renamed to GLErr_Unknown to solve conflict with winioctl.h */
|
||||
static unsigned int GLErr_InvalidEnum;
|
||||
|
@ -165,7 +166,7 @@ glsl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc,
|
|||
|
||||
if (begun) {
|
||||
begun = 0;
|
||||
vid.end_rendering ();
|
||||
vid.vid_internal->end_rendering ();
|
||||
}
|
||||
|
||||
vr_data.realtime = realtime;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "QF/GLSL/funcs.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
// First we need to get all the function pointers declared.
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
|
@ -74,9 +75,9 @@ qboolean
|
|||
EGLF_FindFunctions (void)
|
||||
{
|
||||
#define QFGL_WANT(ret, name, args) \
|
||||
qfe##name = vid.get_proc_address (#name, false);
|
||||
qfe##name = vid.vid_internal->get_proc_address (#name, false);
|
||||
#define QFGL_NEED(ret, name, args) \
|
||||
qfe##name = vid.get_proc_address (#name, true);
|
||||
qfe##name = vid.vid_internal->get_proc_address (#name, true);
|
||||
#include "QF/GLSL/qf_funcs_list.h"
|
||||
#undef QFGL_NEED
|
||||
#undef QFGL_WANT
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "QF/plugin/general.h"
|
||||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
cvar_t *vidrend_plugin;
|
||||
plugin_t *vidrendmodule = NULL;
|
||||
|
@ -76,8 +77,8 @@ R_LoadModule (void (*load_gl)(void), void (*set_palette) (const byte *palette))
|
|||
r_funcs = vidrendmodule->functions->vid_render;
|
||||
mod_funcs = r_funcs->model_funcs;
|
||||
r_data = vidrendmodule->data->vid_render;
|
||||
r_data->vid->load_gl = load_gl;
|
||||
r_data->vid->set_palette = set_palette;
|
||||
r_data->vid->vid_internal->load_gl = load_gl;
|
||||
r_data->vid->vid_internal->set_palette = set_palette;
|
||||
|
||||
vidrendmodule->functions->general->p_Init ();
|
||||
}
|
||||
|
|
|
@ -56,9 +56,9 @@ D_Init (void)
|
|||
r_worldpolysbacktofront = false;
|
||||
r_recursiveaffinetriangles = true;
|
||||
|
||||
vr_data.vid->surf_cache_size = D_SurfaceCacheForRes;
|
||||
vr_data.vid->flush_caches = D_FlushCaches;
|
||||
vr_data.vid->init_caches = D_InitCaches;
|
||||
vr_data.vid->vid_internal->surf_cache_size = D_SurfaceCacheForRes;
|
||||
vr_data.vid->vid_internal->flush_caches = D_FlushCaches;
|
||||
vr_data.vid->vid_internal->init_caches = D_InitCaches;
|
||||
|
||||
VID_InitBuffers ();
|
||||
}
|
||||
|
|
|
@ -825,5 +825,5 @@ Draw_BlendScreen (quat_t color)
|
|||
newpal[2] = vid.gammatable[b];
|
||||
newpal += 3;
|
||||
}
|
||||
vid.set_palette (pal);
|
||||
vid.vid_internal->set_palette (pal);
|
||||
}
|
||||
|
|
|
@ -66,9 +66,9 @@ sw32_D_Init (void)
|
|||
sw32_d_zitable[i] = (65536.0 * 65536.0 / (double) i);
|
||||
}
|
||||
|
||||
vr_data.vid->surf_cache_size = sw32_D_SurfaceCacheForRes;
|
||||
vr_data.vid->flush_caches = sw32_D_FlushCaches;
|
||||
vr_data.vid->init_caches = sw32_D_InitCaches;
|
||||
vr_data.vid->vid_internal->surf_cache_size = sw32_D_SurfaceCacheForRes;
|
||||
vr_data.vid->vid_internal->flush_caches = sw32_D_FlushCaches;
|
||||
vr_data.vid->vid_internal->init_caches = sw32_D_InitCaches;
|
||||
|
||||
VID_InitBuffers ();
|
||||
VID_MakeColormaps();
|
||||
|
|
|
@ -1299,7 +1299,7 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
newpal[2] = vid.gammatable[b];
|
||||
newpal += 3;
|
||||
}
|
||||
vid.set_palette (pal);
|
||||
vid.vid_internal->set_palette (pal);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
#include "gl/namehack.h"
|
||||
|
||||
|
@ -126,9 +127,9 @@ vid_render_funcs_t gl_vid_render_funcs = {
|
|||
static void
|
||||
gl_vid_render_init (void)
|
||||
{
|
||||
vr_data.vid->set_palette = GL_SetPalette;
|
||||
vr_data.vid->init_gl = GL_Init_Common;
|
||||
vr_data.vid->load_gl ();
|
||||
vr_data.vid->vid_internal->set_palette = GL_SetPalette;
|
||||
vr_data.vid->vid_internal->init_gl = GL_Init_Common;
|
||||
vr_data.vid->vid_internal->load_gl ();
|
||||
vr_funcs = &gl_vid_render_funcs;
|
||||
m_funcs = &model_funcs;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
#include "glsl/namehack.h"
|
||||
|
||||
|
@ -126,9 +127,9 @@ vid_render_funcs_t glsl_vid_render_funcs = {
|
|||
static void
|
||||
glsl_vid_render_init (void)
|
||||
{
|
||||
vr_data.vid->set_palette = GLSL_SetPalette;
|
||||
vr_data.vid->init_gl = GLSL_Init_Common;
|
||||
vr_data.vid->load_gl ();
|
||||
vr_data.vid->vid_internal->set_palette = GLSL_SetPalette;
|
||||
vr_data.vid->vid_internal->init_gl = GLSL_Init_Common;
|
||||
vr_data.vid->vid_internal->load_gl ();
|
||||
vr_funcs = &glsl_vid_render_funcs;
|
||||
m_funcs = &model_funcs;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "mod_internal.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
#include "vulkan/namehack.h"
|
||||
|
||||
|
@ -134,9 +135,9 @@ set_palette (const byte *palette)
|
|||
static void
|
||||
vulkan_vid_render_init (void)
|
||||
{
|
||||
vr_data.vid->set_palette = set_palette;
|
||||
vr_data.vid->init_gl = Vulkan_Init_Common;
|
||||
vr_data.vid->load_gl ();
|
||||
vr_data.vid->vid_internal->set_palette = set_palette;
|
||||
vr_data.vid->vid_internal->init_gl = Vulkan_Init_Common;
|
||||
vr_data.vid->vid_internal->load_gl ();
|
||||
vr_funcs = &vulkan_vid_render_funcs;
|
||||
m_funcs = &model_funcs;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ VID_UpdateGamma (cvar_t *vid_gamma)
|
|||
VID_BuildGammaTable (gamma);
|
||||
for (i = 0; i < 256 * 3; i++)
|
||||
viddef.palette[i] = viddef.gammatable[viddef.basepal[i]];
|
||||
viddef.set_palette (viddef.palette); // update with the new palette
|
||||
viddef.vid_internal->set_palette (viddef.palette); // update with the new palette
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,8 +256,9 @@ VID_InitBuffers (void)
|
|||
// Calculate the sizes we want first
|
||||
buffersize = viddef.rowbytes * viddef.height;
|
||||
zbuffersize = viddef.width * viddef.height * sizeof (*viddef.zbuffer);
|
||||
if (viddef.surf_cache_size)
|
||||
cachesize = viddef.surf_cache_size (viddef.width, viddef.height);
|
||||
if (viddef.vid_internal->surf_cache_size)
|
||||
cachesize = viddef.vid_internal->surf_cache_size (viddef.width,
|
||||
viddef.height);
|
||||
|
||||
// Free the old z-buffer
|
||||
if (viddef.zbuffer) {
|
||||
|
@ -266,13 +267,13 @@ VID_InitBuffers (void)
|
|||
}
|
||||
// Free the old surface cache
|
||||
if (viddef.surfcache) {
|
||||
if (viddef.flush_caches)
|
||||
viddef.flush_caches ();
|
||||
if (viddef.vid_internal->flush_caches)
|
||||
viddef.vid_internal->flush_caches ();
|
||||
free (viddef.surfcache);
|
||||
viddef.surfcache = NULL;
|
||||
}
|
||||
if (viddef.do_screen_buffer) {
|
||||
viddef.do_screen_buffer ();
|
||||
if (viddef.vid_internal->do_screen_buffer) {
|
||||
viddef.vid_internal->do_screen_buffer ();
|
||||
} else {
|
||||
// Free the old screen buffer
|
||||
if (viddef.buffer) {
|
||||
|
@ -302,13 +303,13 @@ VID_InitBuffers (void)
|
|||
Sys_Error ("Not enough memory for video mode");
|
||||
}
|
||||
|
||||
if (viddef.init_caches)
|
||||
viddef.init_caches (viddef.surfcache, cachesize);
|
||||
if (viddef.vid_internal->init_caches)
|
||||
viddef.vid_internal->init_caches (viddef.surfcache, cachesize);
|
||||
}
|
||||
|
||||
void
|
||||
VID_ClearMemory (void)
|
||||
{
|
||||
if (viddef.flush_caches)
|
||||
viddef.flush_caches ();
|
||||
if (viddef.vid_internal->flush_caches)
|
||||
viddef.vid_internal->flush_caches ();
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ SDL_Surface *screen = NULL;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
static vid_internal_t vid_internal;
|
||||
|
||||
static void (*set_vid_mode) (Uint32 flags);
|
||||
|
||||
static void (GLAPIENTRY *qfglFinish) (void);
|
||||
|
@ -157,7 +159,7 @@ sdlgl_set_vid_mode (Uint32 flags)
|
|||
success:
|
||||
viddef.numpages = 2;
|
||||
|
||||
viddef.init_gl ();
|
||||
viddef.vid_internal->init_gl ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -170,8 +172,8 @@ sdlgl_end_rendering (void)
|
|||
static void
|
||||
sdl_load_gl (void)
|
||||
{
|
||||
viddef.get_proc_address = QFGL_ProcAddress;
|
||||
viddef.end_rendering = sdlgl_end_rendering;
|
||||
viddef.vid_internal->get_proc_address = QFGL_ProcAddress;
|
||||
viddef.vid_internal->end_rendering = sdlgl_end_rendering;
|
||||
set_vid_mode = sdlgl_set_vid_mode;
|
||||
|
||||
if (SDL_GL_LoadLibrary (gl_driver->string) != 0)
|
||||
|
@ -220,7 +222,7 @@ sdl_set_vid_mode (Uint32 flags)
|
|||
// now know everything we need to know about the buffer
|
||||
VGA_width = viddef.width;
|
||||
VGA_height = viddef.height;
|
||||
viddef.do_screen_buffer = do_screen_buffer;
|
||||
viddef.vid_internal->do_screen_buffer = do_screen_buffer;
|
||||
VGA_pagebase = viddef.buffer = screen->pixels;
|
||||
VGA_rowbytes = viddef.rowbytes = screen->pitch;
|
||||
viddef.conbuffer = viddef.buffer;
|
||||
|
@ -235,6 +237,8 @@ VID_Init (byte *palette, byte *colormap)
|
|||
{
|
||||
Uint32 flags;
|
||||
|
||||
viddef.vid_internal = &vid_internal;
|
||||
|
||||
set_vid_mode = sdl_set_vid_mode;
|
||||
|
||||
// Load the SDL library
|
||||
|
@ -269,7 +273,7 @@ VID_Init (byte *palette, byte *colormap)
|
|||
|
||||
VID_SDL_GammaCheck ();
|
||||
VID_InitGamma (palette);
|
||||
viddef.set_palette (viddef.palette);
|
||||
viddef.vid_internal->set_palette (viddef.palette);
|
||||
|
||||
viddef.initialized = true;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
#include "dga_check.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
static vid_internal_t vid_internal;
|
||||
int XShmGetEventBase (Display *x); // for broken X11 headers
|
||||
|
||||
static GC x_gc;
|
||||
|
@ -209,7 +210,7 @@ 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 ();
|
||||
viddef.vid_internal->init_gl ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -227,8 +228,8 @@ glx_load_gl (void)
|
|||
choose_visual = glx_choose_visual;
|
||||
create_context = glx_create_context;
|
||||
|
||||
viddef.get_proc_address = QFGL_ProcAddress;
|
||||
viddef.end_rendering = glx_end_rendering;
|
||||
viddef.vid_internal->get_proc_address = QFGL_ProcAddress;
|
||||
viddef.vid_internal->end_rendering = glx_end_rendering;
|
||||
|
||||
#ifdef RTLD_GLOBAL
|
||||
flags |= RTLD_GLOBAL;
|
||||
|
@ -623,7 +624,7 @@ x11_create_context (void)
|
|||
x_shmeventtype = XShmGetEventBase (x_disp) + ShmCompletion;
|
||||
}
|
||||
|
||||
viddef.do_screen_buffer = x11_init_buffers;
|
||||
viddef.vid_internal->do_screen_buffer = x11_init_buffers;
|
||||
VID_InitBuffers ();
|
||||
|
||||
// XSynchronize (x_disp, False);
|
||||
|
@ -666,6 +667,8 @@ VID_SetPalette (const byte *palette)
|
|||
void
|
||||
VID_Init (byte *palette, byte *colormap)
|
||||
{
|
||||
viddef.vid_internal = &vid_internal;
|
||||
|
||||
choose_visual = x11_choose_visual;
|
||||
create_context = x11_create_context;
|
||||
|
||||
|
@ -686,7 +689,7 @@ VID_Init (byte *palette, byte *colormap)
|
|||
create_context ();
|
||||
|
||||
VID_InitGamma (palette);
|
||||
viddef.set_palette (viddef.palette);
|
||||
viddef.vid_internal->set_palette (viddef.palette);
|
||||
|
||||
Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n",
|
||||
viddef.width, viddef.height);
|
||||
|
|
Loading…
Reference in a new issue