From 8e91fb7bc15bcf8760fae6376316fad3c970ef3f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 14 Feb 2012 19:47:02 +0900 Subject: [PATCH] Get the basics linking. Still, nothing will work: no plugins are loaded and they're all broken anyway. glx, sgl, glslx etc are going away, just the basics will be built: fbdev (probably go away eventually), sdl, x11 and hopefully someday win. That's actually the only reason anything links. --- config.d/build_control.m4 | 2 +- include/QF/plugin/vid_render.h | 14 ++ include/QF/render.h | 19 +++ include/QF/screen.h | 2 - include/QF/vid.h | 2 + include/d_iface.h | 20 +-- include/r_cvar.h | 4 - include/r_screen.h | 2 + libs/models/Makefile.am | 8 +- libs/video/renderer/r_cvar.c | 10 -- libs/video/targets/context_sdl.c | 3 +- libs/video/targets/context_x11.c | 17 +- libs/video/targets/in_x11.c | 13 +- libs/video/targets/vid.c | 32 ++-- libs/video/targets/vid_common_glsl.c | 1 - libs/video/targets/vid_common_sw.c | 68 ++++---- libs/video/targets/vid_common_sw32.c | 1 - libs/video/targets/vid_fbdev.c | 79 +++++----- libs/video/targets/vid_glx.c | 1 - libs/video/targets/vid_sdl.c | 29 ++-- libs/video/targets/vid_sdl32.c | 1 - libs/video/targets/vid_sgl.c | 1 - libs/video/targets/vid_x11.c | 62 ++++---- nq/source/sbar.c | 2 + qw/include/client.h | 9 +- qw/source/Makefile.am | 9 +- qw/source/cl_cam.c | 18 +-- qw/source/cl_demo.c | 2 +- qw/source/cl_entparse.c | 4 +- qw/source/cl_ents.c | 65 ++++---- qw/source/cl_input.c | 2 +- qw/source/cl_main.c | 48 +++--- qw/source/cl_ngraph.c | 34 ++-- qw/source/cl_parse.c | 33 ++-- qw/source/cl_screen.c | 42 ++--- qw/source/cl_tent.c | 47 +++--- qw/source/cl_view.c | 82 +++++----- qw/source/sbar.c | 227 ++++++++++++++------------- 38 files changed, 520 insertions(+), 495 deletions(-) diff --git a/config.d/build_control.m4 b/config.d/build_control.m4 index d2c8e66b7..69b749d40 100644 --- a/config.d/build_control.m4 +++ b/config.d/build_control.m4 @@ -5,7 +5,7 @@ dnl ================================================================== QF_WITH_TARGETS( clients, [ --with-clients= compile clients in :], - [3dfx,fbdev,glx,glslx,mgl,sdl,sdl32,sgl,sglsl,svga,wgl,x11],dummy + [fbdev,sdl,svga,x11],dummy ) QF_WITH_TARGETS( servers, diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index 64ac00951..0d56773eb 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -69,6 +69,14 @@ typedef struct vid_particle_funcs_s { void (*R_TeleportSplash) (const vec3_t org); void (*R_DarkFieldParticles) (const struct entity_s *ent); void (*R_EntityParticles) (const struct entity_s *ent); + + void (*R_Particle_New) (ptype_t type, int texnum, const vec3_t org, + float scale, const vec3_t vel, float die, + int color, float alpha, float ramp); + void (*R_Particle_NewRandom) (ptype_t type, int texnum, const vec3_t org, + int org_fuzz, float scale, int vel_fuzz, + float die, int color, float alpha, + float ramp); } vid_particle_funcs_t; typedef struct vid_render_funcs_s { @@ -104,6 +112,9 @@ typedef struct vid_render_funcs_s { void (*SCR_DrawTurtle) (void); void (*SCR_DrawPause) (void); struct tex_s *(*SCR_CaptureBGR) (void); + struct tex_s *(*SCR_ScreenShot) (int width, int height); + void (*SCR_DrawStringToSnap) (const char *s, struct tex_s *tex, + int x, int y); void (*Fog_Update) (float density, float red, float green, float blue, float time); @@ -114,6 +125,8 @@ typedef struct vid_render_funcs_s { void (*R_NewMap) (model_t *worldmodel, model_t **models, int num_models); void (*R_AddEfrags) (entity_t *ent); void (*R_RemoveEfrags) (entity_t *ent); + void (*R_EnqueueEntity) (struct entity_s *ent); //FIXME should not be here + void (*R_LineGraph) (int x, int y, int *h_vals, int count); dlight_t *(*R_AllocDlight) (int key); entity_t *(*R_AllocEntity) (void); void (*R_RenderView) (void); @@ -132,6 +145,7 @@ typedef struct vid_render_data_s { int scr_fullupdate; // set to 0 to force full redraw void (*viewsize_callback) (struct cvar_s *); struct cvar_s *scr_viewsize; + struct cvar_s *graphheight; float min_wateralpha; qboolean active; qboolean force_fullscreen; diff --git a/include/QF/render.h b/include/QF/render.h index 4f1f197e4..ff0bde3a7 100644 --- a/include/QF/render.h +++ b/include/QF/render.h @@ -34,6 +34,25 @@ #include "QF/qdefs.h" // FIXME #include "QF/vid.h" +typedef enum { + pt_static, + pt_grav, + pt_slowgrav, + pt_fire, + pt_explode, + pt_explode2, + pt_blob, + pt_blob2, + pt_smoke, + pt_smokecloud, + pt_bloodcloud, + pt_fadespark, + pt_fadespark2, + pt_fallfade, + pt_fallfadespark, + pt_flame +} ptype_t; + extern struct vid_render_funcs_s *r_funcs; extern struct vid_render_data_s *r_data; diff --git a/include/QF/screen.h b/include/QF/screen.h index d08105907..d55fbd8c7 100644 --- a/include/QF/screen.h +++ b/include/QF/screen.h @@ -47,8 +47,6 @@ void SCR_EndLoadingPlaque (void); struct view_s; -struct tex_s *SCR_ScreenShot (int width, int height); -void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y); int MipColor (int r, int g, int b); int SCR_ModalMessage (const char *text); diff --git a/include/QF/vid.h b/include/QF/vid.h index ec481b394..b687f90c5 100644 --- a/include/QF/vid.h +++ b/include/QF/vid.h @@ -78,6 +78,8 @@ typedef struct { void (*do_screen_buffer)(void); } viddef_t; +extern viddef_t viddef; + extern unsigned short d_8to16table[256]; extern unsigned int d_8to24table[256]; diff --git a/include/d_iface.h b/include/d_iface.h index cd71477ec..0af6a859b 100644 --- a/include/d_iface.h +++ b/include/d_iface.h @@ -31,6 +31,7 @@ #include "QF/mathlib.h" #include "QF/model.h" +#include "QF/render.h" #include "QF/vid.h" #define WARP_WIDTH 320 @@ -45,25 +46,6 @@ typedef struct float zi; } emitpoint_t; -typedef enum { - pt_static, - pt_grav, - pt_slowgrav, - pt_fire, - pt_explode, - pt_explode2, - pt_blob, - pt_blob2, - pt_smoke, - pt_smokecloud, - pt_bloodcloud, - pt_fadespark, - pt_fadespark2, - pt_fallfade, - pt_fallfadespark, - pt_flame -} ptype_t; - typedef enum { part_tex_dot, part_tex_spark, diff --git a/include/r_cvar.h b/include/r_cvar.h index 7fb69cd90..0d95e7de1 100644 --- a/include/r_cvar.h +++ b/include/r_cvar.h @@ -28,7 +28,6 @@ extern struct cvar_s *gl_fb_models; extern struct cvar_s *gl_finish; extern struct cvar_s *gl_keeptjunctions; extern struct cvar_s *gl_lerp_anim; -extern struct cvar_s *gl_driver; extern struct cvar_s *gl_lightmap_align; extern struct cvar_s *gl_lightmap_subimage; extern struct cvar_s *gl_max_size; @@ -73,9 +72,6 @@ extern struct cvar_s *r_maxedges; extern struct cvar_s *r_maxsurfs; extern struct cvar_s *r_mirroralpha; extern struct cvar_s *r_nearclip; -extern struct cvar_s *r_netgraph; -extern struct cvar_s *r_netgraph_alpha; -extern struct cvar_s *r_netgraph_box; extern struct cvar_s *r_norefresh; extern struct cvar_s *r_novis; extern struct cvar_s *r_numedges; diff --git a/include/r_screen.h b/include/r_screen.h index 667f62b8b..d78db5517 100644 --- a/include/r_screen.h +++ b/include/r_screen.h @@ -43,6 +43,8 @@ void SCR_DrawTime (void); void SCR_DrawTurtle (void); void SCR_DrawPause (void); struct tex_s *SCR_CaptureBGR (void); +struct tex_s *SCR_ScreenShot (int width, int height); +void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y); extern int scr_copytop; diff --git a/libs/models/Makefile.am b/libs/models/Makefile.am index db8992fbd..d52809a57 100644 --- a/libs/models/Makefile.am +++ b/libs/models/Makefile.am @@ -10,7 +10,7 @@ EXTRA_LTLIBRARIES= libQFmodels_gl.la libQFmodels_glsl.la libQFmodels_sw.la lib_ldflags=-version-info $(QUAKE_LIBRARY_VERSION_INFO) \ -rpath $(libdir) -no-undefined -models_sources = clip_hull.c model.c portal.c skin.c trace.c winding.c +models_sources = clip_hull.c model.c portal.c trace.c winding.c common_libs = \ $(top_builddir)/libs/image/libQFimage.la \ @@ -23,7 +23,7 @@ libQFmodels_la_LIBADD= $(models_libs) libQFmodels_la_DEPENDENCIES= $(models_libs) libQFmodels_la_SOURCES= $(models_sources) null_model.c -gl_sources=gl_model_fullbright.c gl_skin.c +gl_sources=gl_model_fullbright.c gl_skin.c skin.c gl_libs= \ alias/libalias_gl.la \ brush/libbrush_gl.la \ @@ -41,7 +41,7 @@ glsl_libs= \ libQFmodels_glsl_la_LDFLAGS= $(lib_ldflags) libQFmodels_glsl_la_LIBADD= $(glsl_libs) libQFmodels_glsl_la_DEPENDENCIES= $(glsl_libs) -libQFmodels_glsl_la_SOURCES= $(models_sources) glsl_skin.c +libQFmodels_glsl_la_SOURCES= $(models_sources) glsl_skin.c skin.c sw_libs= \ alias/libalias_sw.la \ @@ -51,4 +51,4 @@ sw_libs= \ libQFmodels_sw_la_LDFLAGS= $(lib_ldflags) libQFmodels_sw_la_LIBADD= $(sw_libs) libQFmodels_sw_la_DEPENDENCIES= $(sw_libs) -libQFmodels_sw_la_SOURCES= $(models_sources) sw_skin.c +libQFmodels_sw_la_SOURCES= $(models_sources) sw_skin.c skin.c diff --git a/libs/video/renderer/r_cvar.c b/libs/video/renderer/r_cvar.c index b5817f50b..b34431146 100644 --- a/libs/video/renderer/r_cvar.c +++ b/libs/video/renderer/r_cvar.c @@ -102,9 +102,6 @@ cvar_t *r_maxedges; cvar_t *r_maxsurfs; cvar_t *r_mirroralpha; cvar_t *r_nearclip; -cvar_t *r_netgraph; -cvar_t *r_netgraph_alpha; -cvar_t *r_netgraph_box; cvar_t *r_norefresh; cvar_t *r_novis; cvar_t *r_numedges; @@ -369,13 +366,6 @@ R_Init_Cvars (void) r_nearclip = Cvar_Get ("r_nearclip", "4", CVAR_ARCHIVE, r_nearclip_f, "Distance of the near clipping plane from the " "player."); - r_netgraph = Cvar_Get ("r_netgraph", "0", CVAR_NONE, NULL, - "Toggle the display of a graph showing network " - "performance"); - r_netgraph_alpha = Cvar_Get ("r_netgraph_alpha", "0.5", CVAR_ARCHIVE, NULL, - "Net graph translucency"); - r_netgraph_box = Cvar_Get ("r_netgraph_box", "1", CVAR_ARCHIVE, NULL, - "Draw box around net graph"); r_norefresh = Cvar_Get ("r_norefresh_", "0", CVAR_NONE, NULL, "Set to 1 to disable display refresh"); r_novis = Cvar_Get ("r_novis", "0", CVAR_NONE, NULL, "Set to 1 to enable " diff --git a/libs/video/targets/context_sdl.c b/libs/video/targets/context_sdl.c index 8f8224e10..69bf3f009 100644 --- a/libs/video/targets/context_sdl.c +++ b/libs/video/targets/context_sdl.c @@ -22,7 +22,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "context_sdl.h" -#include "r_internal.h" cvar_t *vid_bitdepth; @@ -68,7 +67,7 @@ VID_Shutdown (void) static void VID_UpdateFullscreen (cvar_t *vid_fullscreen) { - if (!vid.initialized) + if (!viddef.initialized) return; if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN)) || (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN)) diff --git a/libs/video/targets/context_x11.c b/libs/video/targets/context_x11.c index 699354d59..5d53d8cbc 100644 --- a/libs/video/targets/context_x11.c +++ b/libs/video/targets/context_x11.c @@ -76,7 +76,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "context_x11.h" #include "dga_check.h" -#include "r_internal.h" static void (*event_handlers[LASTEvent]) (XEvent *); qboolean oktodraw = false; @@ -342,8 +341,8 @@ check_mouse_event (Display *disp, XEvent *ev, XPointer arg) XMotionEvent *me = &ev->xmotion; if (ev->type != MotionNotify) return False; - if ((unsigned) me->x != vid.width / 2 - || (unsigned) me->y != vid.height / 2) + if ((unsigned) me->x != viddef.width / 2 + || (unsigned) me->y != viddef.height / 2) return False; return True; } @@ -355,7 +354,7 @@ X11_SetMouse (void) XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, 0, 0); XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, - vid.width / 2, vid.height / 2); + viddef.width / 2, viddef.height / 2); XPeekIfEvent (x_disp, &ev, check_mouse_event, 0); x_mouse_time = ev.xmotion.time; } @@ -439,8 +438,8 @@ X11_SetVidMode (int width, int height) } for (i = 0; i < nummodes; i++) { - if ((vidmodes[i]->hdisplay == vid.width) && - (vidmodes[i]->vdisplay == vid.height)) { + if ((vidmodes[i]->hdisplay == viddef.width) && + (vidmodes[i]->vdisplay == viddef.height)) { found_mode = true; best_mode = i; break; @@ -449,7 +448,7 @@ X11_SetVidMode (int width, int height) if (found_mode) { Sys_MaskPrintf (SYS_VID, "VID: Chose video mode: %dx%d\n", - vid.width, vid.height); + viddef.width, viddef.height); XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[best_mode]); @@ -457,7 +456,7 @@ X11_SetVidMode (int width, int height) X11_SetScreenSaver (); } else { Sys_Printf ("VID: Mode %dx%d can't go fullscreen.\n", - vid.width, vid.height); + viddef.width, viddef.height); vidmode_avail = vidmode_active = false; } } @@ -479,7 +478,7 @@ X11_UpdateFullscreen (cvar_t *fullscreen) return; } else { set_fullscreen (1); - X11_SetVidMode (vid.width, vid.height); + X11_SetVidMode (viddef.width, viddef.height); X11_SetMouse (); IN_UpdateGrab (in_grab); } diff --git a/libs/video/targets/in_x11.c b/libs/video/targets/in_x11.c index df21b8c86..02fa5c4e2 100644 --- a/libs/video/targets/in_x11.c +++ b/libs/video/targets/in_x11.c @@ -80,7 +80,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "compat.h" #include "context_x11.h" #include "dga_check.h" -#include "r_internal.h" cvar_t *in_snd_block; cvar_t *in_dga; @@ -683,11 +682,11 @@ center_pointer (void) event.type = MotionNotify; event.xmotion.display = x_disp; event.xmotion.window = x_win; - event.xmotion.x = vid.width / 2; - event.xmotion.y = vid.height / 2; + event.xmotion.x = viddef.width / 2; + event.xmotion.y = viddef.height / 2; XSendEvent (x_disp, x_win, False, PointerMotionMask, &event); XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, - vid.width / 2, vid.height / 2); + viddef.width / 2, viddef.height / 2); } static void @@ -706,11 +705,11 @@ event_motion (XEvent *event) } else { if (vid_fullscreen->int_val || input_grabbed) { if (!event->xmotion.send_event) { - unsigned dist_x = abs (vid.width / 2 - event->xmotion.x); - unsigned dist_y = abs (vid.height / 2 - event->xmotion.y); + unsigned dist_x = abs (viddef.width / 2 - event->xmotion.x); + unsigned dist_y = abs (viddef.height / 2 - event->xmotion.y); in_mouse_x += (event->xmotion.x - p_mouse_x); in_mouse_y += (event->xmotion.y - p_mouse_y); - if (dist_x > vid.width / 4 || dist_y > vid.height / 4) { + if (dist_x > viddef.width / 4 || dist_y > viddef.height / 4) { center_pointer (); } } diff --git a/libs/video/targets/vid.c b/libs/video/targets/vid.c index f0baefd40..758ab12a5 100644 --- a/libs/video/targets/vid.c +++ b/libs/video/targets/vid.c @@ -48,10 +48,10 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "compat.h" -#include "r_internal.h" /* Software and hardware gamma support */ VISIBLE byte gammatable[256]; +viddef_t viddef; byte *vid_colormap; cvar_t *vid_gamma; cvar_t *vid_system_gamma; @@ -138,14 +138,14 @@ VID_GetWindowSize (int def_w, int def_h) Cvar_SetFlags (vid_width, vid_width->flags | CVAR_ROM); Cvar_SetFlags (vid_height, vid_height->flags | CVAR_ROM); - vid.width = vid_width->int_val; - vid.height = vid_height->int_val; + viddef.width = vid_width->int_val; + viddef.height = vid_height->int_val; - vid.aspect = ((vid_aspect->vec[0] * vid.height) - / (vid_aspect->vec[1] * vid.width)); + viddef.aspect = ((vid_aspect->vec[0] * viddef.height) + / (vid_aspect->vec[1] * viddef.width)); - con_width = Cvar_Get ("con_width", va ("%d", vid.width), CVAR_NONE, NULL, - "console effective width (GL only)"); + con_width = Cvar_Get ("con_width", va ("%d", viddef.width), CVAR_NONE, + NULL, "console effective width (GL only)"); if ((pnum = COM_CheckParm ("-conwidth"))) { if (pnum >= com_argc - 1) Sys_Error ("VID: -conwidth "); @@ -154,9 +154,9 @@ VID_GetWindowSize (int def_w, int def_h) // make con_width a multiple of 8 and >= 320 Cvar_Set (con_width, va ("%d", max (con_width->int_val & ~7, 320))); Cvar_SetFlags (con_width, con_width->flags | CVAR_ROM); - vid.conwidth = con_width->int_val; + viddef.conwidth = con_width->int_val; - conheight = (vid.conwidth * vid_aspect->vec[1]) / vid_aspect->vec[0]; + conheight = (viddef.conwidth * vid_aspect->vec[1]) / vid_aspect->vec[0]; con_height = Cvar_Get ("con_height", va ("%d", conheight), CVAR_NONE, NULL, "console effective height (GL only)"); if ((pnum = COM_CheckParm ("-conheight"))) { @@ -167,7 +167,7 @@ VID_GetWindowSize (int def_w, int def_h) // make con_height >= 200 Cvar_Set (con_height, va ("%d", max (con_height->int_val, 200))); Cvar_SetFlags (con_height, con_height->flags | CVAR_ROM); - vid.conheight = con_height->int_val; + viddef.conheight = con_height->int_val; Con_CheckResize (); // Now that we have a window size, fix console } @@ -205,20 +205,20 @@ VID_UpdateGamma (cvar_t *vid_gamma) { double gamma = bound (0.1, vid_gamma->value, 9.9); - vid.recalc_refdef = 1; // force a surface cache flush + viddef.recalc_refdef = 1; // force a surface cache flush if (vid_gamma_avail && vid_system_gamma->int_val) { // Have system, use it Sys_MaskPrintf (SYS_VID, "Setting hardware gamma to %g\n", gamma); VID_BuildGammaTable (1.0); // hardware gamma wants a linear palette VID_SetGamma (gamma); - memcpy (vid.palette, vid.basepal, 256 * 3); + memcpy (viddef.palette, viddef.basepal, 256 * 3); } else { // We have to hack the palette int i; Sys_MaskPrintf (SYS_VID, "Setting software gamma to %g\n", gamma); VID_BuildGammaTable (gamma); for (i = 0; i < 256 * 3; i++) - vid.palette[i] = gammatable[vid.basepal[i]]; - VID_SetPalette (vid.palette); // update with the new palette + viddef.palette[i] = gammatable[viddef.basepal[i]]; + VID_SetPalette (viddef.palette); // update with the new palette } } @@ -233,8 +233,8 @@ VID_InitGamma (unsigned char *pal) int i; double gamma = 1.45; - vid.basepal = pal; - vid.palette = malloc (256 * 3); + viddef.basepal = pal; + viddef.palette = malloc (256 * 3); if ((i = COM_CheckParm ("-gamma"))) { gamma = atof (com_argv[i + 1]); } diff --git a/libs/video/targets/vid_common_glsl.c b/libs/video/targets/vid_common_glsl.c index 879abb898..a2ca4b63e 100644 --- a/libs/video/targets/vid_common_glsl.c +++ b/libs/video/targets/vid_common_glsl.c @@ -56,7 +56,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "compat.h" #include "d_iface.h" -#include "r_internal.h" VISIBLE int glsl_palette; VISIBLE int glsl_colormap; diff --git a/libs/video/targets/vid_common_sw.c b/libs/video/targets/vid_common_sw.c index 62fed8577..ace9188d4 100644 --- a/libs/video/targets/vid_common_sw.c +++ b/libs/video/targets/vid_common_sw.c @@ -39,8 +39,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/sys.h" #include "QF/vid.h" -#include "r_internal.h" - unsigned short d_8to16table[256]; void @@ -49,61 +47,61 @@ VID_InitBuffers (void) int buffersize, zbuffersize, cachesize = 1; // No console scaling in the sw renderer - vid.conwidth = vid.width; - vid.conheight = vid.height; + viddef.conwidth = viddef.width; + viddef.conheight = viddef.height; Con_CheckResize (); // Calculate the sizes we want first - buffersize = vid.rowbytes * vid.height; - zbuffersize = vid.width * vid.height * sizeof (*vid.zbuffer); - if (vid.surf_cache_size) - cachesize = vid.surf_cache_size (vid.width, vid.height); + 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); // Free the old z-buffer - if (vid.zbuffer) { - free (vid.zbuffer); - vid.zbuffer = NULL; + if (viddef.zbuffer) { + free (viddef.zbuffer); + viddef.zbuffer = NULL; } // Free the old surface cache - if (vid.surfcache) { - if (vid.flush_caches) - vid.flush_caches (); - free (vid.surfcache); - vid.surfcache = NULL; + if (viddef.surfcache) { + if (viddef.flush_caches) + viddef.flush_caches (); + free (viddef.surfcache); + viddef.surfcache = NULL; } - if (vid.do_screen_buffer) { - vid.do_screen_buffer (); + if (viddef.do_screen_buffer) { + viddef.do_screen_buffer (); } else { // Free the old screen buffer - if (vid.buffer) { - free (vid.buffer); - vid.conbuffer = vid.buffer = NULL; + if (viddef.buffer) { + free (viddef.buffer); + viddef.conbuffer = viddef.buffer = NULL; } // Allocate the new screen buffer - vid.conbuffer = vid.buffer = calloc (buffersize, 1); - if (!vid.conbuffer) { + viddef.conbuffer = viddef.buffer = calloc (buffersize, 1); + if (!viddef.conbuffer) { Sys_Error ("Not enough memory for video mode"); } } // Allocate the new z-buffer - vid.zbuffer = calloc (zbuffersize, 1); - if (!vid.zbuffer) { - free (vid.buffer); - vid.conbuffer = vid.buffer = NULL; + viddef.zbuffer = calloc (zbuffersize, 1); + if (!viddef.zbuffer) { + free (viddef.buffer); + viddef.conbuffer = viddef.buffer = NULL; Sys_Error ("Not enough memory for video mode"); } // Allocate the new surface cache; free the z-buffer if we fail - vid.surfcache = calloc (cachesize, 1); - if (!vid.surfcache) { - free (vid.buffer); - free (vid.zbuffer); - vid.conbuffer = vid.buffer = NULL; - vid.zbuffer = NULL; + viddef.surfcache = calloc (cachesize, 1); + if (!viddef.surfcache) { + free (viddef.buffer); + free (viddef.zbuffer); + viddef.conbuffer = viddef.buffer = NULL; + viddef.zbuffer = NULL; Sys_Error ("Not enough memory for video mode"); } - if (vid.init_caches) - vid.init_caches (vid.surfcache, cachesize); + if (viddef.init_caches) + viddef.init_caches (viddef.surfcache, cachesize); } void diff --git a/libs/video/targets/vid_common_sw32.c b/libs/video/targets/vid_common_sw32.c index 365043c49..f8ee97da6 100644 --- a/libs/video/targets/vid_common_sw32.c +++ b/libs/video/targets/vid_common_sw32.c @@ -40,7 +40,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "compat.h" -#include "r_internal.h" VISIBLE unsigned short d_8to16table[256]; unsigned char d_15to8table[65536]; diff --git a/libs/video/targets/vid_fbdev.c b/libs/video/targets/vid_fbdev.c index 3d04d434d..b75b658bb 100644 --- a/libs/video/targets/vid_fbdev.c +++ b/libs/video/targets/vid_fbdev.c @@ -74,7 +74,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "d_iface.h" -#include "r_internal.h" #include "fbset.h" #ifndef PAGE_SIZE @@ -106,10 +105,10 @@ D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height) { int i, j, reps, repshift, offset, off; - if (!fbdev_inited || !vid.direct || fbdev_backgrounded) + if (!fbdev_inited || !viddef.direct || fbdev_backgrounded) return; - if (vid.aspect > 1.5) { + if (viddef.aspect > 1.5) { reps = 2; repshift = 1; } else { @@ -120,10 +119,10 @@ D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height) for (i = 0; i < (height << repshift); i += reps) { for (j = 0; j < reps; j++) { offset = x + ((y << repshift) + i + j) - * vid.rowbytes; + * viddef.rowbytes; off = offset % 0x10000; - memcpy (&backingbuf[(i + j) * 24], vid.direct + off, width); - memcpy (vid.direct + off, + memcpy (&backingbuf[(i + j) * 24], viddef.direct + off, width); + memcpy (viddef.direct + off, &pbitmap[(i >> repshift) * width], width); } } @@ -134,10 +133,10 @@ D_EndDirectRect (int x, int y, int width, int height) { int i, j, reps, repshift, offset, off; - if (!fbdev_inited || !vid.direct || fbdev_backgrounded) + if (!fbdev_inited || !viddef.direct || fbdev_backgrounded) return; - if (vid.aspect > 1.5) { + if (viddef.aspect > 1.5) { reps = 2; repshift = 1; } else { @@ -148,9 +147,9 @@ D_EndDirectRect (int x, int y, int width, int height) for (i = 0; i < (height << repshift); i += reps) { for (j = 0; j < reps; j++) { offset = x + ((y << repshift) + i + j) - * vid.rowbytes; + * viddef.rowbytes; off = offset % 0x10000; - memcpy (vid.direct + off, &backingbuf[(i + j) * 24], width); + memcpy (viddef.direct + off, &backingbuf[(i + j) * 24], width); } } } @@ -305,13 +304,13 @@ VID_SetMode (const char *name, unsigned char *palette) current_mode = *vmode; strncpy(current_name, current_mode.name, sizeof(current_name)-1); current_name[31] = 0; - vid.width = vmode->xres; - vid.height = vmode->yres; - vid.rowbytes = vmode->xres * (vmode->depth >> 3); - vid.colormap8 = (byte *) vid_colormap; - vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES]; - vid.conrowbytes = vid.rowbytes; - vid.numpages = 1; + viddef.width = vmode->xres; + viddef.height = vmode->yres; + viddef.rowbytes = vmode->xres * (vmode->depth >> 3); + viddef.colormap8 = (byte *) vid_colormap; + viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES]; + viddef.conrowbytes = viddef.rowbytes; + viddef.numpages = 1; if (fb_map_addr) { if (munmap(fb_map_addr, fb_map_length) == -1) { @@ -338,7 +337,7 @@ VID_SetMode (const char *name, unsigned char *palette) fb_fd, 0); if (!fb_map_addr) Sys_Error ("This mode isn't hapnin'"); - vid.direct = framebuffer_ptr = fb_map_addr; + viddef.direct = framebuffer_ptr = fb_map_addr; // alloc screen buffer, z-buffer, and surface cache VID_InitBuffers (); @@ -348,7 +347,7 @@ VID_SetMode (const char *name, unsigned char *palette) } /* Force a surface cache flush */ - vid.recalc_refdef = 1; + viddef.recalc_refdef = 1; return 1; } @@ -414,17 +413,18 @@ VID_Init (byte *palette, byte *colormap) vid_colormap = colormap; if (COM_CheckParm ("-novideo")) { - vid.width = 320; - vid.height = 200; - vid.rowbytes = 320; - vid.aspect = ((float) vid.height / (float) vid.width) * (4.0 / 3.0); - vid.colormap8 = (byte *) vid_colormap; - vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES]; - vid.conrowbytes = vid.rowbytes; - vid.conwidth = vid.width; - vid.conheight = vid.height; - vid.numpages = 1; - vid.basepal = palette; + viddef.width = 320; + viddef.height = 200; + viddef.rowbytes = 320; + viddef.aspect = ((float) viddef.height + / (float) viddef.width) * (4.0 / 3.0); + viddef.colormap8 = (byte *) vid_colormap; + viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES]; + viddef.conrowbytes = viddef.rowbytes; + viddef.conwidth = viddef.width; + viddef.conheight = viddef.height; + viddef.numpages = 1; + viddef.basepal = palette; Con_CheckResize (); // Now that we have a window size, fix console VID_InitBuffers (); return; @@ -450,9 +450,9 @@ VID_Init (byte *palette, byte *colormap) /* Interpret command-line params */ VID_GetWindowSize (320, 200); - modestr = get_mode (vid.width, vid.height, 8); + modestr = get_mode (viddef.width, viddef.height, 8); - /* Set vid parameters */ + /* Set viddef parameters */ vmode = FindVideoMode(modestr); if (!vmode) Sys_Error("no video mode %s", modestr); @@ -461,9 +461,9 @@ VID_Init (byte *palette, byte *colormap) VID_SetMode (current_mode.name, palette); VID_InitGamma (palette); - VID_SetPalette (vid.palette); + VID_SetPalette (viddef.palette); - vid.initialized = true; + viddef.initialized = true; } void @@ -499,8 +499,9 @@ VID_Update (vrect_t *rects) } if (vid_redrawfull->int_val) { - double *d = (double *)framebuffer_ptr, *s = (double *)vid.buffer; - double *ends = (double *)(vid.buffer + vid.height*vid.rowbytes); + double *d = (double *)framebuffer_ptr, *s = (double *)viddef.buffer; + double *ends = (double *)(viddef.buffer + + viddef.height*viddef.rowbytes); while (s < ends) *d++ = *s++; } else { @@ -512,9 +513,9 @@ VID_Update (vrect_t *rects) width = rects->width / sizeof(double); xoff = rects->x; yoff = rects->y; - lineskip = (vid.width - (xoff + rects->width)) / sizeof(double); - d = (double *)(framebuffer_ptr + yoff * vid.rowbytes + xoff); - s = (double *)(vid.buffer + yoff * vid.rowbytes + xoff); + lineskip = (viddef.width - (xoff + rects->width)) / sizeof(double); + d = (double *)(framebuffer_ptr + yoff * viddef.rowbytes + xoff); + s = (double *)(viddef.buffer + yoff * viddef.rowbytes + xoff); for (i = yoff; i < height; i++) { for (j = xoff; j < width; j++) *d++ = *s++; diff --git a/libs/video/targets/vid_glx.c b/libs/video/targets/vid_glx.c index df37bafb0..18c93ab49 100644 --- a/libs/video/targets/vid_glx.c +++ b/libs/video/targets/vid_glx.c @@ -67,7 +67,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "compat.h" #include "context_x11.h" -#include "r_internal.h" #define WARP_WIDTH 320 #define WARP_HEIGHT 200 diff --git a/libs/video/targets/vid_sdl.c b/libs/video/targets/vid_sdl.c index 9f94f037c..0a3fc49d6 100644 --- a/libs/video/targets/vid_sdl.c +++ b/libs/video/targets/vid_sdl.c @@ -48,7 +48,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "d_iface.h" -#include "r_internal.h" #ifdef _WIN32 // FIXME: evil hack to get full DirectSound support with SDL #include @@ -103,25 +102,25 @@ VID_Init (byte *palette, byte *colormap) flags |= SDL_FULLSCREEN; // Initialize display - if (!(screen = SDL_SetVideoMode (vid.width, vid.height, 8, flags))) + if (!(screen = SDL_SetVideoMode (viddef.width, viddef.height, 8, flags))) Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ()); vid_colormap = colormap; VID_InitGamma (palette); - VID_SetPalette (vid.palette); + VID_SetPalette (viddef.palette); // now know everything we need to know about the buffer - VGA_width = vid.width; - VGA_height = vid.height; - vid.numpages = 1; - vid.colormap8 = vid_colormap; - vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES]; - vid.do_screen_buffer = do_screen_buffer; - VGA_pagebase = vid.buffer = screen->pixels; - VGA_rowbytes = vid.rowbytes = screen->pitch; - vid.conbuffer = vid.buffer; - vid.conrowbytes = vid.rowbytes; - vid.direct = 0; + VGA_width = viddef.width; + VGA_height = viddef.height; + viddef.numpages = 1; + viddef.colormap8 = vid_colormap; + viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES]; + viddef.do_screen_buffer = do_screen_buffer; + VGA_pagebase = viddef.buffer = screen->pixels; + VGA_rowbytes = viddef.rowbytes = screen->pitch; + viddef.conbuffer = viddef.buffer; + viddef.conrowbytes = viddef.rowbytes; + viddef.direct = 0; VID_InitBuffers (); // allocate z buffer and surface cache @@ -136,7 +135,7 @@ VID_Init (byte *palette, byte *colormap) mainwindow=GetActiveWindow(); #endif - vid.initialized = true; + viddef.initialized = true; } void diff --git a/libs/video/targets/vid_sdl32.c b/libs/video/targets/vid_sdl32.c index dcf319b3d..a342e5b42 100644 --- a/libs/video/targets/vid_sdl32.c +++ b/libs/video/targets/vid_sdl32.c @@ -49,7 +49,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "d_iface.h" #include "d_local.h" -#include "r_internal.h" #ifdef _WIN32 // FIXME: evil hack to get full DirectSound support with SDL #include diff --git a/libs/video/targets/vid_sgl.c b/libs/video/targets/vid_sgl.c index 013095610..a2f259c12 100644 --- a/libs/video/targets/vid_sgl.c +++ b/libs/video/targets/vid_sgl.c @@ -52,7 +52,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "compat.h" #include "context_sdl.h" -#include "r_internal.h" #ifdef _WIN32 // FIXME: evil hack to get full DirectSound support with SDL # include diff --git a/libs/video/targets/vid_x11.c b/libs/video/targets/vid_x11.c index bb1ace576..224375a45 100644 --- a/libs/video/targets/vid_x11.c +++ b/libs/video/targets/vid_x11.c @@ -76,11 +76,12 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/va.h" #include "QF/vid.h" +#include "QF/plugin/vid_render.h" + #include "compat.h" #include "context_x11.h" #include "d_iface.h" #include "dga_check.h" -#include "r_internal.h" int XShmGetEventBase (Display *x); // for broken X11 headers @@ -218,7 +219,7 @@ st2_fixup (XImage *framebuf, int x, int y, int width, int height) return; for (yi = y; yi < (y + height); yi++) { - src = &((byte *)vid.buffer)[yi * vid.width]; + src = &((byte *)viddef.buffer)[yi * viddef.width]; dest = (PIXEL16 *) &framebuf->data[yi * framebuf->bytes_per_line]; for (xi = x; xi < x + width; xi++) { dest[xi] = st2d_8to16table[src[xi]]; @@ -238,7 +239,7 @@ st3_fixup (XImage * framebuf, int x, int y, int width, int height) return; for (yi = y; yi < (y + height); yi++) { - src = &((byte *)vid.buffer)[yi * vid.width + x]; + src = &((byte *)viddef.buffer)[yi * viddef.width + x]; dest = (PIXEL24 *) &framebuf->data[yi * framebuf->bytes_per_line + x]; // Duff's Device @@ -294,14 +295,14 @@ ResetFrameBuffer (void) if (pwidth == 3) pwidth = 4; - mem = ((vid.width * pwidth + 7) & ~7) * vid.height; + mem = ((viddef.width * pwidth + 7) & ~7) * viddef.height; buf = malloc (mem); SYS_CHECKMEM (buf); // allocate new screen buffer x_framebuffer[0] = XCreateImage (x_disp, x_vis, x_visinfo->depth, - ZPixmap, 0, buf, vid.width, - vid.height, 32, 0); + ZPixmap, 0, buf, viddef.width, + viddef.height, 32, 0); if (!x_framebuffer[0]) { Sys_Error ("VID: XCreateImage failed"); @@ -327,7 +328,7 @@ ResetSharedFrameBuffers (void) // create the image x_framebuffer[frm] = XShmCreateImage (x_disp, x_vis, x_visinfo->depth, ZPixmap, 0, &x_shminfo[frm], - vid.width, vid.height); + viddef.width, viddef.height); // grab shared memory size = x_framebuffer[frm]->bytes_per_line * x_framebuffer[frm]->height; @@ -368,20 +369,20 @@ x11_init_buffers (void) current_framebuffer = 0; - vid.direct = 0; - vid.rowbytes = vid.width; + viddef.direct = 0; + viddef.rowbytes = viddef.width; if (x_visinfo->depth != 8) { - if (vid.buffer) - free (vid.buffer); - vid.buffer = calloc (vid.width, vid.height); - if (!vid.buffer) + if (viddef.buffer) + free (viddef.buffer); + viddef.buffer = calloc (viddef.width, viddef.height); + if (!viddef.buffer) Sys_Error ("Not enough memory for video mode"); } else { - vid.buffer = x_framebuffer[current_framebuffer]->data; + viddef.buffer = x_framebuffer[current_framebuffer]->data; } - vid.conbuffer = vid.buffer; + viddef.conbuffer = viddef.buffer; - vid.conrowbytes = vid.rowbytes; + viddef.conrowbytes = viddef.rowbytes; } static void @@ -452,7 +453,6 @@ x11_choose_visual (void) static void x11_create_context (void) { - // create the GC { XGCValues xgcvalues; @@ -482,7 +482,7 @@ x11_create_context (void) x_shmeventtype = XShmGetEventBase (x_disp) + ShmCompletion; } - vid.do_screen_buffer = x11_init_buffers; + viddef.do_screen_buffer = x11_init_buffers; VID_InitBuffers (); // XSynchronize (x_disp, False); @@ -499,28 +499,28 @@ x11_create_context (void) void VID_Init (byte *palette, byte *colormap) { - vid.numpages = 2; - vid.colormap8 = vid_colormap = colormap; - vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES]; + viddef.numpages = 2; + viddef.colormap8 = vid_colormap = colormap; + viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES]; srandom (getpid ()); VID_GetWindowSize (320, 200); X11_OpenDisplay (); x11_choose_visual (); - X11_SetVidMode (vid.width, vid.height); - X11_CreateWindow (vid.width, vid.height); + X11_SetVidMode (viddef.width, viddef.height); + X11_CreateWindow (viddef.width, viddef.height); X11_CreateNullCursor (); // hide mouse pointer x11_create_context (); VID_InitGamma (palette); - VID_SetPalette (vid.palette); + VID_SetPalette (viddef.palette); Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n", - vid.width, vid.height); + viddef.width, viddef.height); - vid.initialized = true; - vid.recalc_refdef = 1; // force a surface cache flush + viddef.initialized = true; + viddef.recalc_refdef = 1; // force a surface cache flush } void @@ -585,12 +585,12 @@ VID_Update (vrect_t *rects) if (config_notify) { fprintf (stderr, "config notify\n"); config_notify = 0; - vid.width = config_notify_width & ~7; - vid.height = config_notify_height; + viddef.width = config_notify_width & ~7; + viddef.height = config_notify_height; VID_InitBuffers (); - vid.recalc_refdef = 1; /* force a surface cache flush */ + viddef.recalc_refdef = 1; /* force a surface cache flush */ Con_CheckResize (); return; } @@ -629,7 +629,7 @@ VID_Update (vrect_t *rects) } } XSync (x_disp, False); - scr_fullupdate = 0; + r_data->scr_fullupdate = 0; } void diff --git a/nq/source/sbar.c b/nq/source/sbar.c index cfbcdddc6..2e63673fb 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -210,6 +210,8 @@ static void hud_sbar_f (cvar_t *var) { r_data->vid->recalc_refdef = true; + if (r_data->scr_viewsize) + calc_sb_lines (r_data->scr_viewsize); r_data->lineadj = var->int_val ? sb_lines : 0; if (con_module) { if (var->int_val) { diff --git a/qw/include/client.h b/qw/include/client.h index d4933786c..ca82b4d68 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -34,11 +34,11 @@ #include "QF/vid.h" #include "QF/zone.h" +#include "QF/plugin/vid_render.h" + #include "netchan.h" #include "qw/bothdefs.h" #include "qw/protocol.h" -#include "r_local.h" -#include "QF/render.h" /* @@ -304,12 +304,17 @@ typedef struct // all player information player_info_t players[MAX_CLIENTS]; + + lightstyle_t lightstyle[MAX_LIGHTSTYLES]; } client_state_t; /* cvars */ +extern struct cvar_s *r_netgraph; +extern struct cvar_s *r_netgraph_alpha; +extern struct cvar_s *r_netgraph_box; extern struct cvar_s *cl_upspeed; extern struct cvar_s *cl_forwardspeed; extern struct cvar_s *cl_backspeed; diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index 6f683ad8e..2b19d45f6 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -117,8 +117,7 @@ libqw_client_a_SOURCES= \ # Software-rendering clients -# We need libQFrenderer_sw to always be static -- there's assembler in there -soft_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer_sw.la \ +soft_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer.la \ $(top_builddir)/libs/models/libQFmodels_sw.la # ... Linux FBDev @@ -163,7 +162,7 @@ qw_client_sdl32_libs= \ libqw_sdl.a \ $(client_libs) \ $(cl_plugin_LIBS) \ - $(top_builddir)/libs/video/renderer/libQFrenderer_sw32.la \ + $(top_builddir)/libs/video/renderer/libQFrenderer.la \ $(top_builddir)/libs/models/libQFmodels_sw.la \ $(top_builddir)/libs/video/targets/libQFsdl32.la \ $(client_LIBS) @@ -200,10 +199,10 @@ qw_client_x11_DEPENDENCIES= $(qw_client_x11_libs) # OpenGL-using clients -opengl_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer_gl.la \ +opengl_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer.la \ $(top_builddir)/libs/models/libQFmodels_gl.la -glsl_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer_glsl.la \ +glsl_LIBS= $(top_builddir)/libs/video/renderer/libQFrenderer.la \ $(top_builddir)/libs/models/libQFmodels_glsl.la # ... OpenGL in X Window diff --git a/qw/source/cl_cam.c b/qw/source/cl_cam.c index e4c328057..822a4387d 100644 --- a/qw/source/cl_cam.c +++ b/qw/source/cl_cam.c @@ -718,14 +718,14 @@ Chase_Update (void) // the angles are automatically changed to look toward the player if (chase_active->int_val == 3) - VectorCopy (r_refdef.vieworg, player_origin); + VectorCopy (r_data->refdef->vieworg, player_origin); AngleVectors (camera_angles, forward, right, up); VectorScale (forward, chase_back->value, forward); VectorSubtract (player_origin, forward, camera_origin); if (chase_active->int_val == 2) { - VectorCopy (r_refdef.vieworg, player_origin); + VectorCopy (r_data->refdef->vieworg, player_origin); // don't let camera get too low if (camera_origin[2] < player_origin[2] + chase_up->value) @@ -751,14 +751,14 @@ Chase_Update (void) if (VectorLength (stop) != 0) VectorSubtract (stop, forward, camera_origin); - VectorSubtract (camera_origin, r_refdef.vieworg, dir); + VectorSubtract (camera_origin, r_data->refdef->vieworg, dir); VectorCopy (dir, forward); VectorNormalize (forward); if (chase_active->int_val == 2) { if (dir[1] == 0 && dir[0] == 0) { // look straight up or down -// camera_angles[YAW] = r_refdef.viewangles[YAW]; +// camera_angles[YAW] = r_data->refdef->viewangles[YAW]; if (dir[2] > 0) camera_angles[PITCH] = 90; else @@ -781,8 +781,8 @@ Chase_Update (void) } } - VectorCopy (camera_angles, r_refdef.viewangles); // rotate camera - VectorCopy (camera_origin, r_refdef.vieworg); // move camera + VectorCopy (camera_angles, r_data->refdef->viewangles);// rotate camera + VectorCopy (camera_origin, r_data->refdef->vieworg); // move camera // get basic movement from keyboard @@ -846,15 +846,15 @@ Chase_Update (void) // calc exact destination for (i = 0; i < 3; i++) - camera_origin[i] = r_refdef.vieworg[i] + camera_origin[i] = r_data->refdef->vieworg[i] - forward[i] * chase_back->value - right[i] * chase_right->value; camera_origin[2] += chase_up->value; // check for walls between player and camera - TraceLine (r_refdef.vieworg, camera_origin, stop); + TraceLine (r_data->refdef->vieworg, camera_origin, stop); if (VectorLength (stop) != 0) for (i = 0; i < 3; i++) camera_origin[i] = stop[i] + forward[i] * 8; - VectorCopy (camera_origin, r_refdef.vieworg); + VectorCopy (camera_origin, r_data->refdef->vieworg); } diff --git a/qw/source/cl_demo.c b/qw/source/cl_demo.c index 39adb3637..37a41d184 100644 --- a/qw/source/cl_demo.c +++ b/qw/source/cl_demo.c @@ -844,7 +844,7 @@ CL_Record (const char *argv1, int track) for (i = 0; i < MAX_LIGHTSTYLES; i++) { MSG_WriteByte (&buf, svc_lightstyle); MSG_WriteByte (&buf, (char) i); - MSG_WriteString (&buf, r_lightstyle[i].map); + MSG_WriteString (&buf, cl.lightstyle[i].map); } for (i = 0; i < MAX_CL_STATS; i++) { diff --git a/qw/source/cl_entparse.c b/qw/source/cl_entparse.c index 32a62fbae..f28b594bc 100644 --- a/qw/source/cl_entparse.c +++ b/qw/source/cl_entparse.c @@ -58,8 +58,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "d_iface.h" #include "host.h" #include "qw/pmove.h" -#include "r_cvar.h" -#include "r_dynamic.h" #include "clview.h" static struct predicted_player { @@ -308,7 +306,7 @@ CL_ParsePacketEntities (qboolean delta) if (word & U_REMOVE) { // Clear the entity entity_t *ent = &cl_packet_ents[newnum]; if (ent->efrag) - R_RemoveEfrags (ent); + r_funcs->R_RemoveEfrags (ent); memset (ent, 0, sizeof (entity_t)); oldindex++; continue; diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 97f744ea9..c93065680 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -57,8 +57,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "d_iface.h" #include "host.h" #include "qw/pmove.h" -#include "r_cvar.h" -#include "r_dynamic.h" #include "clview.h" entity_t cl_player_ents[MAX_CLIENTS]; @@ -95,7 +93,7 @@ CL_NewDlight (int key, vec3_t org, int effects, byte glow_size, return; } - dl = R_AllocDlight (key); + dl = r_funcs->R_AllocDlight (key); if (!dl) return; VectorCopy (org, dl->origin); @@ -226,7 +224,7 @@ CL_LinkPacketEntities (void) || (cl_deadbodyfilter->int_val && is_dead_body (s1)) || (cl_gibfilter->int_val && is_gib (s1))) { if (ent->efrag) - R_RemoveEfrags (ent); + r_funcs->R_RemoveEfrags (ent); continue; } @@ -276,11 +274,11 @@ CL_LinkPacketEntities (void) VectorCopy (s1->origin, ent->origin); if (!VectorCompare (ent->origin, ent->old_origin)) { // the entity moved, it must be relinked - R_RemoveEfrags (ent); + r_funcs->R_RemoveEfrags (ent); } } if (!ent->efrag) - R_AddEfrags (ent); + r_funcs->R_AddEfrags (ent); if (model->flags & EF_ROTATE) { // rotate binary objects locally vec3_t ang; @@ -297,29 +295,31 @@ CL_LinkPacketEntities (void) continue; if (model->flags & EF_ROCKET) { - dl = R_AllocDlight (-s1->number); + dl = r_funcs->R_AllocDlight (-s1->number); if (dl) { VectorCopy (ent->origin, dl->origin); dl->radius = 200.0; dl->die = cl.time + 0.1; - VectorCopy (r_firecolor->vec, dl->color); + //FIXME VectorCopy (r_firecolor->vec, dl->color); + VectorSet (0.9, 0.7, 0.0, dl->color); dl->color[3] = 0.7; } - R_RocketTrail (ent); + r_funcs->particles->R_RocketTrail (ent); } else if (model->flags & EF_GRENADE) - R_GrenadeTrail (ent); + r_funcs->particles->R_GrenadeTrail (ent); else if (model->flags & EF_GIB) - R_BloodTrail (ent); + r_funcs->particles->R_BloodTrail (ent); else if (model->flags & EF_ZOMGIB) - R_SlightBloodTrail (ent); + r_funcs->particles->R_SlightBloodTrail (ent); else if (model->flags & EF_TRACER) - R_WizTrail (ent); + r_funcs->particles->R_WizTrail (ent); else if (model->flags & EF_TRACER2) - R_FlameTrail (ent); + r_funcs->particles->R_FlameTrail (ent); else if (model->flags & EF_TRACER3) - R_VoorTrail (ent); + r_funcs->particles->R_VoorTrail (ent); else if (model->flags & EF_GLOWTRAIL) - R_GlowTrail (ent, s1->glow_color); + if (r_funcs->particles->R_GlowTrail) + r_funcs->particles->R_GlowTrail (ent, s1->glow_color); } } @@ -371,8 +371,8 @@ CL_AddFlagModels (entity_t *ent, int team, int key) ang[2] -= 45.0; CL_TransformEntity (fent, ang, false); - R_EnqueueEntity (fent); //FIXME should use efrag (needs smarter handling - //in the player code) + r_funcs->R_EnqueueEntity (fent);//FIXME should use efrag (needs smarter + // handling //in the player code) } /* @@ -404,7 +404,7 @@ CL_LinkPlayers (void) j++, info++, state++) { ent = &cl_player_ents[j]; if (ent->efrag) - R_RemoveEfrags (ent); + r_funcs->R_RemoveEfrags (ent); if (state->messagenum != cl.parsecount) continue; // not present this frame @@ -414,7 +414,7 @@ CL_LinkPlayers (void) // spawn light flashes, even ones coming from invisible objects if (j == cl.playernum) { VectorCopy (cl.simorg, org); - r_player_entity = &cl_player_ents[j]; + r_data->player_entity = &cl_player_ents[j]; clientplayer = true; } else { VectorCopy (state->pls.origin, org); @@ -485,7 +485,7 @@ CL_LinkPlayers (void) } // stuff entity in map - R_AddEfrags (ent); + r_funcs->R_AddEfrags (ent); if (state->pls.effects & EF_FLAG1) CL_AddFlagModels (ent, 0, j); @@ -512,7 +512,7 @@ CL_EmitEntities (void) CL_LinkPlayers (); CL_LinkPacketEntities (); CL_UpdateTEnts (); - +#if 0 //FIXME if (!r_drawentities->int_val) { dlight_t *dl; location_t *nearloc; @@ -521,30 +521,33 @@ CL_EmitEntities (void) nearloc = locs_find (r_origin); if (nearloc) { - dl = R_AllocDlight (4096); + dl = r_funcs->R_AllocDlight (4096); if (dl) { VectorCopy (nearloc->loc, dl->origin); dl->radius = 200; - dl->die = r_realtime + 0.1; + dl->die = r_data->realtime + 0.1; dl->color[0] = 0; dl->color[1] = 1; dl->color[2] = 0; dl->color[3] = 0.7; } VectorCopy (nearloc->loc, trueloc); - R_Particle_New (pt_smokecloud, part_tex_smoke, trueloc, 2.0, - vec3_origin, r_realtime + 9.0, 254, - 0.25 + qfrandom (0.125), 0.0); + r_funcs->particles->R_Particle_New (pt_smokecloud, part_tex_smoke, + trueloc, 2.0, + vec3_origin, r_data->realtime + 9.0, 254, + 0.25 + qfrandom (0.125), 0.0); for (i = 0; i < 15; i++) - R_Particle_NewRandom (pt_fallfade, part_tex_dot, trueloc, 12, - 0.7, 96, r_realtime + 5.0, - 104 + (rand () & 7), 1.0, 0.0); + r_funcs->particles->R_Particle_NewRandom (pt_fallfade, + part_tex_dot, trueloc, 12, + 0.7, 96, r_data->realtime + 5.0, + 104 + (rand () & 7), 1.0, 0.0); } } +#endif } void CL_Ents_Init (void) { - r_view_model = &cl.viewent; + r_data->view_model = &cl.viewent; } diff --git a/qw/source/cl_input.c b/qw/source/cl_input.c index 51aaf5d4f..ae681a1ad 100644 --- a/qw/source/cl_input.c +++ b/qw/source/cl_input.c @@ -535,7 +535,7 @@ CL_BaseMove (usercmd_t *cmd) vec3_t forward, right, up, f, r; vec3_t dir = {0, 0, 0}; - dir[1] = r_refdef.viewangles[1] - cl.viewangles[1]; + dir[1] = r_data->refdef->viewangles[1] - cl.viewangles[1]; AngleVectors (dir, forward, right, up); VectorScale (forward, cmd->forwardmove, f); VectorScale (right, cmd->sidemove, r); diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 9db3c400c..38a3d77d1 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -112,8 +112,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "host.h" #include "netchan.h" #include "qw/pmove.h" -#include "r_cvar.h" -#include "r_dynamic.h" #include "sbar.h" #include "clview.h" @@ -194,7 +192,6 @@ client_state_t cl; entity_state_t cl_entities[UPDATE_BACKUP][MAX_DEMO_PACKET_ENTITIES]; entity_state_t cl_baselines[MAX_EDICTS]; -efrag_t cl_efrags[MAX_EFRAGS]; double connect_time = -1; // for connection retransmits @@ -400,7 +397,7 @@ CL_ClearState (void) if (cl.serverinfo) Info_Destroy (cl.serverinfo); memset (&cl, 0, sizeof (cl)); - r_force_fullscreen = 0; + r_data->force_fullscreen = 0; // Note: we should probably hack around this and give diff values for // diff gamedirs @@ -415,7 +412,7 @@ CL_ClearState (void) CL_Init_Entity (&cl.viewent); Sys_MaskPrintf (SYS_DEV, "Clearing memory\n"); - D_FlushCaches (); + r_funcs->D_FlushCaches (); Mod_ClearAll (); if (host_hunklevel) // FIXME: check this... Hunk_FreeToLowMark (host_hunklevel); @@ -423,14 +420,10 @@ CL_ClearState (void) CL_ClearEnts (); CL_ClearTEnts (); - R_ClearState (); + r_funcs->R_ClearState (); SZ_Clear (&cls.netchan.message); - // clear other arrays - memset (cl_efrags, 0, sizeof (cl_efrags)); - memset (r_lightstyle, 0, sizeof (r_lightstyle)); - if (centerprint) dstring_clearstr (centerprint); } @@ -650,7 +643,7 @@ CL_FullServerinfo_f (void) } // R_LoadSkys does the right thing with null pointers. - R_LoadSkys (Info_ValueForKey (cl.serverinfo, "sky")); + r_funcs->R_LoadSkys (Info_ValueForKey (cl.serverinfo, "sky")); } static void @@ -808,7 +801,7 @@ CL_Changing_f (void) S_StopAllSounds (); cl.intermission = 0; - r_force_fullscreen = 0; + r_data->force_fullscreen = 0; CL_SetState (ca_connected); // not active anymore, but not // disconnected Sys_Printf ("\nChanging map...\n"); @@ -1149,7 +1142,7 @@ CL_SetState (cactive_t state) if (old_state == ca_active) { // leaving active state IN_ClearStates (); - r_active = false; + r_data->active = false; Key_SetKeyDest (key_console); // Auto demo recorder stops here @@ -1159,7 +1152,7 @@ CL_SetState (cactive_t state) // entering active state VID_SetCaption (cls.servername->str); IN_ClearStates (); - r_active = true; + r_data->active = true; Key_SetKeyDest (key_game); // Auto demo recorder starts here @@ -1187,7 +1180,6 @@ CL_Init (void) W_LoadWadFile ("gfx.wad"); VID_Init (basepal, colormap); IN_Init (cl_cbuf); - Draw_Init (); Mod_Init (); R_Init (); S_Init (&viewentity, &host_frametime); @@ -1298,7 +1290,6 @@ CL_Init_Cvars (void) VID_Init_Cvars (); IN_Init_Cvars (); Mod_Init_Cvars (); - R_Init_Cvars (); S_Init_Cvars (); CL_Cam_Init_Cvars (); @@ -1309,6 +1300,14 @@ CL_Init_Cvars (void) Team_Init_Cvars (); V_Init_Cvars (); + r_netgraph = Cvar_Get ("r_netgraph", "0", CVAR_NONE, NULL, + "Toggle the display of a graph showing network " + "performance"); + r_netgraph_alpha = Cvar_Get ("r_netgraph_alpha", "0.5", CVAR_ARCHIVE, NULL, + "Net graph translucency"); + r_netgraph_box = Cvar_Get ("r_netgraph_box", "1", CVAR_ARCHIVE, NULL, + "Draw box around net graph"); + cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0); cl_model_crcs = Cvar_Get ("cl_model_crcs", "1", CVAR_ARCHIVE, NULL, @@ -1649,10 +1648,10 @@ Host_Frame (float time) if (host_speeds->int_val) time1 = Sys_DoubleTime (); - r_inhibit_viewmodel = (!Cam_DrawViewModel () - || (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) - || cl.stats[STAT_HEALTH] <= 0); - r_frametime = host_frametime; + r_data->inhibit_viewmodel = (!Cam_DrawViewModel () + || (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) + || cl.stats[STAT_HEALTH] <= 0); + r_data->frametime = host_frametime; CL_UpdateScreen (realtime); @@ -1664,11 +1663,12 @@ Host_Frame (float time) mleaf_t *l; byte *asl = 0; - l = Mod_PointInLeaf (r_origin, cl.worldmodel); + l = Mod_PointInLeaf (r_data->origin, cl.worldmodel); if (l) asl = l->ambient_sound_level; - S_Update (r_origin, vpn, vright, vup, asl); - R_DecayLights (host_frametime); + S_Update (r_data->origin, r_data->vpn, r_data->vright, r_data->vup, + asl); + r_funcs->R_DecayLights (host_frametime); } else S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin, 0); @@ -1684,7 +1684,7 @@ Host_Frame (float time) } if (cls.demo_capture) { - tex_t *tex = SCR_CaptureBGR (); + tex_t *tex = r_funcs->SCR_CaptureBGR (); WritePNGqfs (va ("%s/qfmv%06d.png", qfs_gamedir->dir.shots, cls.demo_capture++), tex->data, tex->width, tex->height); diff --git a/qw/source/cl_ngraph.c b/qw/source/cl_ngraph.c index 73ec96010..2139f3bb4 100644 --- a/qw/source/cl_ngraph.c +++ b/qw/source/cl_ngraph.c @@ -46,9 +46,11 @@ static __attribute__ ((used)) const char rcsid[] = #include "compat.h" #include "cl_parse.h" #include "client.h" -#include "r_cvar.h" //XXX #include "sbar.h" +cvar_t *r_netgraph; +cvar_t *r_netgraph_alpha; +cvar_t *r_netgraph_box; void CL_NetGraph (void) @@ -59,35 +61,39 @@ CL_NetGraph (void) if (!r_netgraph->int_val) return; - x = hudswap ? vid.conwidth - (NET_TIMINGS + 16): 0; - y = vid.conheight - sb_lines - 24 - r_graphheight->int_val - 1; + x = hudswap ? r_data->vid->conwidth - (NET_TIMINGS + 16): 0; + y = r_data->vid->conheight - sb_lines - 24 + - r_data->graphheight->int_val - 1; if (r_netgraph_box->int_val) - Draw_TextBox (x, y, NET_TIMINGS / 8, r_graphheight->int_val / 8 + 1, - r_netgraph_alpha->value * 255); + r_funcs->Draw_TextBox (x, y, NET_TIMINGS / 8, + r_data->graphheight->int_val / 8 + 1, + r_netgraph_alpha->value * 255); lost = CL_CalcNet (); - x = hudswap ? vid.conwidth - (NET_TIMINGS + 8) : 8; - y = vid.conheight - sb_lines - 9; + x = hudswap ? r_data->vid->conwidth - (NET_TIMINGS + 8) : 8; + y = r_data->vid->conheight - sb_lines - 9; l = NET_TIMINGS; - if (l > r_refdef.vrect.width - 8) - l = r_refdef.vrect.width - 8; + if (l > r_data->refdef->vrect.width - 8) + l = r_data->refdef->vrect.width - 8; i = cls.netchan.outgoing_sequence & NET_TIMINGSMASK; a = i - l; if (a < 0) { - R_LineGraph (x, y, &packet_latency[a + NET_TIMINGS], -a); + r_funcs->R_LineGraph (x, y, &packet_latency[a + NET_TIMINGS], -a); x -= a; l += a; a = 0; } - R_LineGraph (x, y, &packet_latency[a], l); + r_funcs->R_LineGraph (x, y, &packet_latency[a], l); - y = vid.conheight - sb_lines - 24 - r_graphheight->int_val + 7; + y = r_data->vid->conheight - sb_lines - 24 + - r_data->graphheight->int_val + 7; snprintf (st, sizeof (st), "%3i%% packet loss", lost); if (hudswap) { - Draw_String (vid.conwidth - ((strlen (st) * 8) + 8), y, st); + r_funcs->Draw_String (r_data->vid->conwidth - ((strlen (st) * 8) + 8), + y, st); } else { - Draw_String (8, y, st); + r_funcs->Draw_String (8, y, st); } } diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 72ccbaa62..d5ea0338b 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -182,7 +182,7 @@ CL_LoadSky (void) const char *name = 0; if (!cl.worldspawn) { - R_LoadSkys (0); + r_funcs->R_LoadSkys (0); return; } if ((item = PL_ObjectForKey (cl.worldspawn, "sky")) // Q2/DarkPlaces @@ -190,7 +190,7 @@ CL_LoadSky (void) || (item = PL_ObjectForKey (cl.worldspawn, "qlsky"))) /* QuakeLives */ { name = PL_String (item); } - R_LoadSkys (name); + r_funcs->R_LoadSkys (name); } int @@ -301,7 +301,7 @@ CL_NewMap (const char *mapname) { cl_static_entities = 0; cl_static_tail = &cl_static_entities; - R_NewMap (cl.worldmodel, cl.model_precache, cl.nummodels); + r_funcs->R_NewMap (cl.worldmodel, cl.model_precache, cl.nummodels); Team_NewMap (); Con_NewMap (); Hunk_Check (); // make sure nothing is hurt @@ -312,7 +312,7 @@ CL_NewMap (const char *mapname) if (cl.edicts) { cl.worldspawn = PL_ObjectAtIndex (cl.edicts, 0); CL_LoadSky (); - Fog_ParseWorldspawn (cl.worldspawn); + r_funcs->Fog_ParseWorldspawn (cl.worldspawn); } } @@ -823,7 +823,7 @@ CL_ParseServerData (void) // get the movevars movevars.gravity = MSG_ReadFloat (net_message); - r_gravity = movevars.gravity; // Gravity for renderer effects + r_data->gravity = movevars.gravity; // Gravity for renderer effects movevars.stopspeed = MSG_ReadFloat (net_message); movevars.maxspeed = MSG_ReadFloat (net_message); movevars.spectatormaxspeed = MSG_ReadFloat (net_message); @@ -972,7 +972,7 @@ CL_ParseStatic (void) CL_ParseBaseline (&es); - ent = R_AllocEntity (); + ent = r_funcs->R_AllocEntity (); CL_Init_Entity (ent); *cl_static_tail = ent; @@ -986,7 +986,7 @@ CL_ParseStatic (void) VectorCopy (es.origin, ent->origin); CL_TransformEntity (ent, es.angles, true); - R_AddEfrags (ent); + r_funcs->R_AddEfrags (ent); } static void @@ -1268,7 +1268,7 @@ CL_MuzzleFlash (void) pl = &cl.frames[parsecountmod].playerstate[i - 1]; - dl = R_AllocDlight (i); + dl = r_funcs->R_AllocDlight (i); if (!dl) return; @@ -1436,15 +1436,16 @@ CL_ParseServerMessage (void) // make sure any stuffed commands are done Cbuf_Execute_Stack (cl_stbuf); CL_ParseServerData (); - vid.recalc_refdef = true; // leave full screen intermission + // leave full screen intermission + r_data->vid->recalc_refdef = true; break; case svc_lightstyle: i = MSG_ReadByte (net_message); if (i >= MAX_LIGHTSTYLES) Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES"); - strcpy (r_lightstyle[i].map, MSG_ReadString (net_message)); - r_lightstyle[i].length = strlen (r_lightstyle[i].map); + strcpy (cl.lightstyle[i].map, MSG_ReadString (net_message)); + cl.lightstyle[i].length = strlen (cl.lightstyle[i].map); break; case svc_sound: @@ -1506,7 +1507,7 @@ CL_ParseServerMessage (void) break; case svc_setpause: - r_paused = cl.paused = MSG_ReadByte (net_message); + r_data->paused = cl.paused = MSG_ReadByte (net_message); if (cl.paused) CDAudio_Pause (); else @@ -1542,9 +1543,9 @@ CL_ParseServerMessage (void) Sys_MaskPrintf (SYS_DEV, "svc_intermission\n"); cl.intermission = 1; - r_force_fullscreen = 1; + r_data->force_fullscreen = 1; cl.completed_time = realtime; - vid.recalc_refdef = true; // go to full screen + r_data->vid->recalc_refdef = true; // go to full screen Sys_MaskPrintf (SYS_DEV, "intermission simorg: "); MSG_ReadCoordV (net_message, cl.simorg); for (i = 0; i < 3; i++) @@ -1564,9 +1565,9 @@ CL_ParseServerMessage (void) case svc_finale: cl.intermission = 2; - r_force_fullscreen = 1; + r_data->force_fullscreen = 1; cl.completed_time = realtime; - vid.recalc_refdef = true; // go to full screen + r_data->vid->recalc_refdef = true; // go to full screen str = MSG_ReadString (net_message); if (strcmp (str, centerprint->str)) { dstring_copystr (centerprint, str); diff --git a/qw/source/cl_screen.c b/qw/source/cl_screen.c index 442b2769e..32434dfde 100644 --- a/qw/source/cl_screen.c +++ b/qw/source/cl_screen.c @@ -55,8 +55,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "client.h" #include "clview.h" #include "compat.h" -#include "r_local.h" -#include "r_cvar.h" #include "sbar.h" @@ -69,7 +67,7 @@ SCR_DrawNet (void) if (cls.demoplayback) return; - Draw_Pic (scr_vrect.x + 64, scr_vrect.y, scr_net); + //FIXME Draw_Pic (r_data->scr_vrect->x + 64, r_data->scr_vrect->y, scr_net); } static void @@ -78,21 +76,21 @@ SCR_CShift (void) mleaf_t *leaf; int contents = CONTENTS_EMPTY; - if (r_active && cl.worldmodel) { - leaf = Mod_PointInLeaf (r_refdef.vieworg, cl.worldmodel); + if (r_data->active && cl.worldmodel) { + leaf = Mod_PointInLeaf (r_data->refdef->vieworg, cl.worldmodel); contents = leaf->contents; } V_SetContentsColor (contents); - Draw_BlendScreen (vid.cshift_color); + r_funcs->Draw_BlendScreen (r_data->vid->cshift_color); } static SCR_Func scr_funcs_normal[] = { - Draw_Crosshair, - SCR_DrawRam, + 0, //Draw_Crosshair, + 0, //SCR_DrawRam, SCR_DrawNet, CL_NetGraph, - SCR_DrawTurtle, - SCR_DrawPause, + 0, //SCR_DrawTurtle, + 0, //SCR_DrawPause, Sbar_DrawCenterPrint, Sbar_Draw, Con_DrawConsole, @@ -127,15 +125,19 @@ CL_UpdateScreen (double realtime) index = 0; // don't allow cheats in multiplayer - if (r_active) { + if (r_data->active) { if (cl.watervis) r_data->min_wateralpha = 0.0; else r_data->min_wateralpha = 1.0; } + scr_funcs_normal[0] = r_funcs->Draw_Crosshair; + scr_funcs_normal[1] = r_funcs->SCR_DrawRam; + scr_funcs_normal[4] = r_funcs->SCR_DrawTurtle; + scr_funcs_normal[5] = r_funcs->SCR_DrawPause; V_PrepBlend (); - SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); + r_funcs->SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); } void @@ -154,27 +156,27 @@ CL_RSShot_f (void) Sys_Printf ("Remote screen shot requested.\n"); - tex = SCR_ScreenShot (RSSHOT_WIDTH, RSSHOT_HEIGHT); + tex = r_funcs->SCR_ScreenShot (RSSHOT_WIDTH, RSSHOT_HEIGHT); if (tex) { time (&now); strcpy (st, ctime (&now)); st[strlen (st) - 1] = 0; - SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, - tex->height - 1); + r_funcs->SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, + tex->height - 1); strncpy (st, cls.servername->str, sizeof (st)); st[sizeof (st) - 1] = 0; - SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, - tex->height - 11); + r_funcs->SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, + tex->height - 11); strncpy (st, cl_name->string, sizeof (st)); st[sizeof (st) - 1] = 0; - SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, - tex->height - 21); + r_funcs->SCR_DrawStringToSnap (st, tex, tex->width - strlen (st) * 8, + tex->height - 21); pcx = EncodePCX (tex->data, tex->width, tex->height, tex->width, - vid.basepal, true, &pcx_len); + r_data->vid->basepal, true, &pcx_len); free (tex); } if (pcx) { diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 76da8994d..b9094fc7d 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -53,7 +53,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "cl_tent.h" #include "client.h" #include "compat.h" -#include "r_dynamic.h" typedef struct tent_s { struct tent_s *next; @@ -237,7 +236,7 @@ beam_clear (beam_t *b) tent_t *t; for (t = b->tents; t; t = t->next) { - R_RemoveEfrags (&t->ent); + r_funcs->R_RemoveEfrags (&t->ent); t->ent.efrag = 0; } free_temp_entities (b->tents); @@ -301,7 +300,7 @@ beam_setup (beam_t *b, qboolean transform) CL_TransformEntity (&tent->ent, ang, true); } VectorCopy (ang, tent->ent.angles); - R_AddEfrags (&tent->ent); + r_funcs->R_AddEfrags (&tent->ent); } } @@ -355,19 +354,19 @@ CL_ParseTEnt (void) switch (type) { case TE_WIZSPIKE: // spike hitting wall MSG_ReadCoordV (net_message, pos); - R_WizSpikeEffect (pos); + r_funcs->particles->R_WizSpikeEffect (pos); S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1); break; case TE_KNIGHTSPIKE: // spike hitting wall MSG_ReadCoordV (net_message, pos); - R_KnightSpikeEffect (pos); + r_funcs->particles->R_KnightSpikeEffect (pos); S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1); break; case TE_SPIKE: // spike hitting wall MSG_ReadCoordV (net_message, pos); - R_SpikeEffect (pos); + r_funcs->particles->R_SpikeEffect (pos); { int i; sfx_t *sound; @@ -383,7 +382,7 @@ CL_ParseTEnt (void) case TE_SUPERSPIKE: // super spike hitting wall MSG_ReadCoordV (net_message, pos); - R_SuperSpikeEffect (pos); + r_funcs->particles->R_SuperSpikeEffect (pos); { int i; sfx_t *sound; @@ -400,10 +399,10 @@ CL_ParseTEnt (void) case TE_EXPLOSION: // rocket explosion // particles MSG_ReadCoordV (net_message, pos); - R_ParticleExplosion (pos); + r_funcs->particles->R_ParticleExplosion (pos); // light - dl = R_AllocDlight (0); + dl = r_funcs->R_AllocDlight (0); if (dl) { VectorCopy (pos, dl->origin); dl->radius = 350; @@ -433,7 +432,7 @@ CL_ParseTEnt (void) case TE_TAREXPLOSION: // tarbaby explosion MSG_ReadCoordV (net_message, pos); - R_BlobExplosion (pos); + r_funcs->particles->R_BlobExplosion (pos); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; @@ -458,12 +457,12 @@ CL_ParseTEnt (void) case TE_LAVASPLASH: MSG_ReadCoordV (net_message, pos); - R_LavaSplash (pos); + r_funcs->particles->R_LavaSplash (pos); break; case TE_TELEPORT: MSG_ReadCoordV (net_message, pos); - R_TeleportSplash (pos); + r_funcs->particles->R_TeleportSplash (pos); break; case TE_EXPLOSION2: // color mapped explosion @@ -471,8 +470,9 @@ CL_ParseTEnt (void) colorStart = MSG_ReadByte (net_message); colorLength = MSG_ReadByte (net_message); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); - R_ParticleExplosion2 (pos, colorStart, colorLength); - dl = R_AllocDlight (0); + r_funcs->particles->R_ParticleExplosion2 (pos, colorStart, + colorLength); + dl = r_funcs->R_AllocDlight (0); if (!dl) break; VectorCopy (pos, dl->origin); @@ -480,27 +480,28 @@ CL_ParseTEnt (void) dl->die = cl.time + 0.5; dl->decay = 300; colorStart = (colorStart + (rand () % colorLength)) * 3; - VectorScale (&vid.palette[colorStart], 1.0 / 255.0, dl->color); + VectorScale (&r_data->vid->palette[colorStart], 1.0 / 255.0, + dl->color); dl->color[3] = 0.7; break; case TE_GUNSHOT: // bullet hitting wall cnt = MSG_ReadByte (net_message) * 20; MSG_ReadCoordV (net_message, pos); - R_GunshotEffect (pos, cnt); + r_funcs->particles->R_GunshotEffect (pos, cnt); break; case TE_BLOOD: // bullet hitting body cnt = MSG_ReadByte (net_message) * 20; MSG_ReadCoordV (net_message, pos); - R_BloodPuffEffect (pos, cnt); + r_funcs->particles->R_BloodPuffEffect (pos, cnt); break; case TE_LIGHTNINGBLOOD: // lightning hitting body MSG_ReadCoordV (net_message, pos); // light - dl = R_AllocDlight (0); + dl = r_funcs->R_AllocDlight (0); if (dl) { VectorCopy (pos, dl->origin); dl->radius = 150; @@ -509,7 +510,7 @@ CL_ParseTEnt (void) QuatSet (0.25, 0.40, 0.65, 1, dl->color); } - R_LightningBloodEffect (pos); + r_funcs->particles->R_LightningBloodEffect (pos); break; default: @@ -575,7 +576,7 @@ CL_UpdateExplosions (void) f = 10 * (cl.time - ex->start); if (f >= ent->model->numframes) { tent_obj_t *_to; - R_RemoveEfrags (ent); + r_funcs->R_RemoveEfrags (ent); ent->efrag = 0; free_temp_entities (ex->tent); _to = *to; @@ -588,7 +589,7 @@ CL_UpdateExplosions (void) ent->frame = f; if (!ent->efrag) - R_AddEfrags (ent); + r_funcs->R_AddEfrags (ent); } } @@ -605,7 +606,7 @@ CL_ClearProjectiles (void) tent_t *tent; for (tent = cl_projectiles; tent; tent = tent->next) { - R_RemoveEfrags (&tent->ent); + r_funcs->R_RemoveEfrags (&tent->ent); tent->ent.efrag = 0; } free_temp_entities (cl_projectiles); @@ -651,7 +652,7 @@ CL_ParseProjectiles (qboolean nail2) pr->angles[2] = 0; CL_TransformEntity (&tent->ent, tent->ent.angles, true); - R_AddEfrags (&tent->ent); + r_funcs->R_AddEfrags (&tent->ent); } *tail = cl_projectiles; diff --git a/qw/source/cl_view.c b/qw/source/cl_view.c index 53c5ccb48..c5b2eb746 100644 --- a/qw/source/cl_view.c +++ b/qw/source/cl_view.c @@ -426,10 +426,10 @@ V_CalcBlend (void) b *= a2; } - vid.cshift_color[0] = min (r, 255.0) / 255.0; - vid.cshift_color[1] = min (g, 255.0) / 255.0; - vid.cshift_color[2] = min (b, 255.0) / 255.0; - vid.cshift_color[3] = bound (0.0, a, 1.0); + r_data->vid->cshift_color[0] = min (r, 255.0) / 255.0; + r_data->vid->cshift_color[1] = min (g, 255.0) / 255.0; + r_data->vid->cshift_color[2] = min (b, 255.0) / 255.0; + r_data->vid->cshift_color[3] = bound (0.0, a, 1.0); } void @@ -441,17 +441,17 @@ V_PrepBlend (void) || (cl.sv_cshifts & INFO_CSHIFT_POWERUP)) V_CalcPowerupCshift (); - vid.cshift_changed = false; + r_data->vid->cshift_changed = false; for (i = 0; i < NUM_CSHIFTS; i++) { if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) { - vid.cshift_changed = true; + r_data->vid->cshift_changed = true; cl.prev_cshifts[i].percent = cl.cshifts[i].percent; } for (j = 0; j < 3; j++) { if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { - vid.cshift_changed = true; + r_data->vid->cshift_changed = true; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; } } @@ -467,7 +467,7 @@ V_PrepBlend (void) if (cl.cshifts[CSHIFT_BONUS].percent < 0) cl.cshifts[CSHIFT_BONUS].percent = 0; - if (!vid.cshift_changed && !vid.recalc_refdef) + if (!r_data->vid->cshift_changed && !r_data->vid->recalc_refdef) return; V_CalcBlend (); @@ -490,12 +490,12 @@ CalcGunAngle (void) float yaw, pitch, move; static float oldpitch = 0, oldyaw = 0; - yaw = r_refdef.viewangles[YAW]; - pitch = -r_refdef.viewangles[PITCH]; + yaw = r_data->refdef->viewangles[YAW]; + pitch = -r_data->refdef->viewangles[PITCH]; - yaw = angledelta (yaw - r_refdef.viewangles[YAW]) * 0.4; + yaw = angledelta (yaw - r_data->refdef->viewangles[YAW]) * 0.4; yaw = bound (-10, yaw, 10); - pitch = angledelta (-pitch - r_refdef.viewangles[PITCH]) * 0.4; + pitch = angledelta (-pitch - r_data->refdef->viewangles[PITCH]) * 0.4; pitch = bound (-10, pitch, 10); move = host_frametime * 20; @@ -518,8 +518,8 @@ CalcGunAngle (void) oldyaw = yaw; oldpitch = pitch; - cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw; - cl.viewent.angles[PITCH] = -(r_refdef.viewangles[PITCH] + pitch); + cl.viewent.angles[YAW] = r_data->refdef->viewangles[YAW] + yaw; + cl.viewent.angles[PITCH] = -(r_data->refdef->viewangles[PITCH] + pitch); } /* @@ -530,11 +530,11 @@ CalcGunAngle (void) static void V_AddIdle (void) { - r_refdef.viewangles[ROLL] += v_idlescale->value * + r_data->refdef->viewangles[ROLL] += v_idlescale->value * sin (cl.time * v_iroll_cycle->value) * v_iroll_level->value; - r_refdef.viewangles[PITCH] += v_idlescale->value * + r_data->refdef->viewangles[PITCH] += v_idlescale->value * sin (cl.time * v_ipitch_cycle->value) * v_ipitch_level->value; - r_refdef.viewangles[YAW] += v_idlescale->value * + r_data->refdef->viewangles[YAW] += v_idlescale->value * sin (cl.time * v_iyaw_cycle->value) * v_iyaw_level->value; cl.viewent.angles[ROLL] -= v_idlescale->value * @@ -556,12 +556,12 @@ V_CalcViewRoll (void) float side; side = V_CalcRoll (cl.simangles, cl.simvel); - r_refdef.viewangles[ROLL] += side; + r_data->refdef->viewangles[ROLL] += side; if (v_dmg_time > 0) { - r_refdef.viewangles[ROLL] += + r_data->refdef->viewangles[ROLL] += v_dmg_time / v_kicktime->value * v_dmg_roll; - r_refdef.viewangles[PITCH] += + r_data->refdef->viewangles[PITCH] += v_dmg_time / v_kicktime->value * v_dmg_pitch; v_dmg_time -= host_frametime; } @@ -577,8 +577,8 @@ V_CalcIntermissionRefdef (void) // view is the weapon model (visible only from inside body) view = &cl.viewent; - VectorCopy (cl.simorg, r_refdef.vieworg); - VectorCopy (cl.simangles, r_refdef.viewangles); + VectorCopy (cl.simorg, r_data->refdef->vieworg); + VectorCopy (cl.simangles, r_data->refdef->viewangles); view->model = NULL; // always idle in intermission @@ -609,30 +609,30 @@ V_CalcRefdef (void) bob = V_CalcBob (); // refresh position from simulated origin - VectorCopy (cl.simorg, r_refdef.vieworg); + VectorCopy (cl.simorg, r_data->refdef->vieworg); - r_refdef.vieworg[2] += bob; + r_data->refdef->vieworg[2] += bob; // never let it sit exactly on a node line, because a water plane can // disappear when viewed with the eye exactly on it. // server protocol specifies to only 1/8 pixel, so add 1/16 in each axis - r_refdef.vieworg[0] += (1.0 / 16.0); - r_refdef.vieworg[1] += (1.0 / 16.0); - r_refdef.vieworg[2] += (1.0 / 16.0); + r_data->refdef->vieworg[0] += (1.0 / 16.0); + r_data->refdef->vieworg[1] += (1.0 / 16.0); + r_data->refdef->vieworg[2] += (1.0 / 16.0); - VectorCopy (cl.simangles, r_refdef.viewangles); + VectorCopy (cl.simangles, r_data->refdef->viewangles); V_CalcViewRoll (); V_AddIdle (); if (view_message->pls.flags & PF_GIB) - r_refdef.vieworg[2] += 8; // gib view height + r_data->refdef->vieworg[2] += 8; // gib view height else if (view_message->pls.flags & PF_DEAD) - r_refdef.vieworg[2] -= 16; // corpse view height + r_data->refdef->vieworg[2] -= 16; // corpse view height else - r_refdef.vieworg[2] += zofs; // view height + r_data->refdef->vieworg[2] += zofs; // view height if (view_message->pls.flags & PF_DEAD) // PF_GIB will also set PF_DEAD - r_refdef.viewangles[ROLL] = 80; // dead view angle + r_data->refdef->viewangles[ROLL] = 80; // dead view angle // offsets AngleVectors (cl.simangles, forward, right, up); @@ -654,15 +654,15 @@ V_CalcRefdef (void) // fudge position around to keep amount of weapon visible // roughly equal with different FOV - if (hud_sbar->int_val == 0 && scr_viewsize->int_val >= 100) + if (hud_sbar->int_val == 0 && r_data->scr_viewsize->int_val >= 100) ; - else if (scr_viewsize->int_val == 110) + else if (r_data->scr_viewsize->int_val == 110) view->origin[2] += 1; - else if (scr_viewsize->int_val == 100) + else if (r_data->scr_viewsize->int_val == 100) view->origin[2] += 2; - else if (scr_viewsize->int_val == 90) + else if (r_data->scr_viewsize->int_val == 90) view->origin[2] += 1; - else if (scr_viewsize->int_val == 80) + else if (r_data->scr_viewsize->int_val == 80) view->origin[2] += 0.5; if (view_message->pls.flags & (PF_GIB | PF_DEAD)) @@ -673,7 +673,7 @@ V_CalcRefdef (void) view->skin = 0; // set up the refresh position - r_refdef.viewangles[PITCH] += cl.punchangle; + r_data->refdef->viewangles[PITCH] += cl.punchangle; // smooth out stair step ups if ((cl.onground != -1) && (cl.simorg[2] - oldz > 0)) { @@ -686,7 +686,7 @@ V_CalcRefdef (void) oldz = cl.simorg[2]; if (cl.simorg[2] - oldz > 12) oldz = cl.simorg[2] - 12; - r_refdef.vieworg[2] += oldz - cl.simorg[2]; + r_data->refdef->vieworg[2] += oldz - cl.simorg[2]; view->origin[2] += oldz - cl.simorg[2]; } else oldz = cl.simorg[2]; @@ -715,7 +715,7 @@ V_RenderView (void) { cl.simangles[ROLL] = 0; // FIXME @@@ - if (!r_active) + if (!r_data->active) return; view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; @@ -728,7 +728,7 @@ V_RenderView (void) V_CalcRefdef (); } - R_RenderView (); + r_funcs->R_RenderView (); } void diff --git a/qw/source/sbar.c b/qw/source/sbar.c index 751acb1e5..f8780377f 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -62,7 +62,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "cl_parse.h" #include "client.h" #include "compat.h" -#include "r_cvar.h" // for scr_printspeed #include "sbar.h" int sb_updates; // if >= vid.numpages, no update needed @@ -102,6 +101,8 @@ cvar_t *hud_sbar; cvar_t *hud_swap; cvar_t *hud_scoreboard_gravity; cvar_t *hud_scoreboard_uid; +cvar_t *scr_centertime; +cvar_t *scr_printspeed; static view_t *sbar_view; static view_t *sbar_inventory_view; @@ -200,10 +201,10 @@ calc_sb_lines (cvar_t *var) static void hud_sbar_f (cvar_t *var) { - vid.recalc_refdef = true; - if (scr_viewsize) - calc_sb_lines (scr_viewsize); - r_lineadj = var->int_val ? sb_lines : 0; + r_data->vid->recalc_refdef = true; + if (r_data->scr_viewsize) + calc_sb_lines (r_data->scr_viewsize); + r_data->lineadj = var->int_val ? sb_lines : 0; if (con_module) { if (var->int_val) { view_remove (con_module->data->console->view, @@ -222,7 +223,7 @@ viewsize_f (cvar_t *var) { calc_sb_lines (var); if (hud_sbar) - r_lineadj = hud_sbar->int_val ? sb_lines : 0; + r_data->lineadj = hud_sbar->int_val ? sb_lines : 0; } @@ -275,30 +276,30 @@ Sbar_Changed (void) static void draw_pic (view_t *view, int x, int y, qpic_t *pic) { - Draw_Pic (view->xabs + x, view->yabs + y, pic); + r_funcs->Draw_Pic (view->xabs + x, view->yabs + y, pic); } static inline void draw_cachepic (view_t *view, int x, int y, const char *name, int cent) { - qpic_t *pic = Draw_CachePic (name, true); + qpic_t *pic = r_funcs->Draw_CachePic (name, true); if (cent) x += (view->xlen - pic->width) / 2; - Draw_Pic (view->xabs + x, view->yabs + y, pic); + r_funcs->Draw_Pic (view->xabs + x, view->yabs + y, pic); } static inline void draw_subpic (view_t *view, int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height) { - Draw_SubPic (view->xabs + x, view->yabs + y, pic, + r_funcs->Draw_SubPic (view->xabs + x, view->yabs + y, pic, srcx, srcy, width, height); } static inline void draw_transpic (view_t *view, int x, int y, qpic_t *pic) { - Draw_Pic (view->xabs + x, view->yabs + y, pic); + r_funcs->Draw_Pic (view->xabs + x, view->yabs + y, pic); } @@ -307,31 +308,31 @@ draw_transpic (view_t *view, int x, int y, qpic_t *pic) static inline void draw_character (view_t *view, int x, int y, int c) { - Draw_Character (view->xabs + x, view->yabs + y, c); + r_funcs->Draw_Character (view->xabs + x, view->yabs + y, c); } static inline void draw_string (view_t *view, int x, int y, const char *str) { - Draw_String (view->xabs + x, view->yabs + y, str); + r_funcs->Draw_String (view->xabs + x, view->yabs + y, str); } static inline void draw_altstring (view_t *view, int x, int y, const char *str) { - Draw_AltString (view->xabs + x, view->yabs + y, str); + r_funcs->Draw_AltString (view->xabs + x, view->yabs + y, str); } static inline void draw_nstring (view_t *view, int x, int y, const char *str, int n) { - Draw_nString (view->xabs + x, view->yabs + y, str, n); + r_funcs->Draw_nString (view->xabs + x, view->yabs + y, str, n); } static inline void draw_fill (view_t *view, int x, int y, int w, int h, int col) { - Draw_Fill (view->xabs + x, view->yabs + y, w, h, col); + r_funcs->Draw_Fill (view->xabs + x, view->yabs + y, w, h, col); } static void @@ -507,7 +508,7 @@ draw_smallnum (view_t *view, int x, int y, int n, int packed, int colored) static void draw_tile (view_t *view) { - Draw_TileClear (view->xabs, view->yabs, view->xlen, view->ylen); + r_funcs->Draw_TileClear (view->xabs, view->yabs, view->xlen, view->ylen); } static void @@ -576,7 +577,7 @@ draw_weapons_hud (view_t *view) if (view->parent->gravity == grav_southeast) x = view->xlen - 24; - for (i = vid.conheight < 204; i < 7; i++) { + for (i = r_data->vid->conheight < 204; i < 7; i++) { if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN << i)) { flashon = calc_flashon (cl.item_gettime[i], IT_SHOTGUN << i); draw_subpic (view, x, i * 16, sb_weapons[flashon][i], 0, 0, 24, 16); @@ -920,12 +921,13 @@ Sbar_Draw (void) sbar_view->visible = 0; - headsup = !(hud_sbar->int_val || scr_viewsize->int_val < 100); + headsup = !(hud_sbar->int_val || r_data->scr_viewsize->int_val < 100); - if ((sb_updates >= vid.numpages) && !headsup) + if ((sb_updates >= r_data->vid->numpages) && !headsup) return; - if (con_module && con_module->data->console->lines == vid.conheight) + if (con_module + && con_module->data->console->lines == r_data->vid->conheight) return; // console is full screen if (cls.state == ca_active @@ -940,7 +942,7 @@ Sbar_Draw (void) sbar_view->visible = 1; - scr_copyeverything = 1; + r_data->scr_copyeverything = 1; sb_updates++; if (sb_showscores || sb_showteamscores || cl.stats[STAT_HEALTH] <= 0) @@ -966,8 +968,8 @@ Sbar_TeamOverlay (view_t *view) return; } - scr_copyeverything = 1; - scr_fullupdate = 0; + r_data->scr_copyeverything = 1; + r_data->scr_fullupdate = 0; draw_cachepic (view, 0, 0, "gfx/ranking.lmp", 1); @@ -1399,7 +1401,7 @@ Sbar_DeathmatchOverlay (view_t *view, int start) int l, y; int skip = 10; - if (vid.conwidth < 244) // FIXME: magic number, gained through experimentation + if (r_data->vid->conwidth < 244) // FIXME: magic number, gained through experimentation return; if (largegame) @@ -1414,8 +1416,8 @@ Sbar_DeathmatchOverlay (view_t *view, int start) } } - scr_copyeverything = 1; - scr_fullupdate = 0; + r_data->scr_copyeverything = 1; + r_data->scr_fullupdate = 0; if (!start) { draw_cachepic (view, 0, 0, "gfx/ranking.lmp", 1); @@ -1450,8 +1452,8 @@ draw_minifrags (view_t *view) char num[20]; player_info_t *s; - scr_copyeverything = 1; - scr_fullupdate = 0; + r_data->scr_copyeverything = 1; + r_data->scr_fullupdate = 0; // scores Sbar_SortFrags (false); @@ -1631,8 +1633,8 @@ draw_stuff (view_t *view) void Sbar_IntermissionOverlay (void) { - scr_copyeverything = 1; - scr_fullupdate = 0; + r_data->scr_copyeverything = 1; + r_data->scr_fullupdate = 0; if (cl.teamplay > 0 && !sb_showscores) Sbar_TeamOverlay (overlay_view); @@ -1693,7 +1695,7 @@ Sbar_DrawCenterString (view_t *view, int remaining) break; x = view->xabs + (view->xlen - l * 8) / 2; for (j = 0; j < l; j++, x += 8) { - Draw_Character (x, y, start[j]); + r_funcs->Draw_Character (x, y, start[j]); if (!remaining--) return; } @@ -1717,7 +1719,7 @@ Sbar_FinaleOverlay (void) if (key_dest != key_game) return; - scr_copyeverything = 1; + r_data->scr_copyeverything = 1; draw_cachepic (overlay_view, 0, 16, "gfx/finale.lmp", 1); // the finale prints the characters one at a time @@ -1728,9 +1730,9 @@ Sbar_FinaleOverlay (void) void Sbar_DrawCenterPrint (void) { - scr_copytop = 1; + r_data->scr_copytop = 1; - centertime_off -= r_frametime; + centertime_off -= r_data->frametime; if (centertime_off <= 0) return; @@ -1748,12 +1750,12 @@ init_sbar_views (void) view_t *minifrags_view = 0; view_t *miniteam_view = 0; - if (vid.conwidth < 512) { + if (r_data->vid->conwidth < 512) { sbar_view = view_new (0, 0, 320, 48, grav_south); sbar_frags_view = view_new (0, 0, 130, 8, grav_northeast); sbar_frags_view->draw = draw_frags; - } else if (vid.conwidth < 640) { + } else if (r_data->vid->conwidth < 640) { sbar_view = view_new (0, 0, 512, 48, grav_south); minifrags_view = view_new (320, 0, 192, 48, grav_southwest); minifrags_view->draw = draw_minifrags; @@ -1815,8 +1817,8 @@ init_sbar_views (void) if (miniteam_view) view_add (sbar_view, miniteam_view); - if (vid.conwidth > 640) { - int l = (vid.conwidth - 640) / 2; + if (r_data->vid->conwidth > 640) { + int l = (r_data->vid->conwidth - 640) / 2; view = view_new (-l, 0, l, 48, grav_southwest); view->draw = draw_tile; @@ -1837,12 +1839,12 @@ init_hud_views (void) view_t *minifrags_view = 0; view_t *miniteam_view = 0; - if (vid.conwidth < 512) { + if (r_data->vid->conwidth < 512) { hud_view = view_new (0, 0, 320, 48, grav_south); hud_frags_view = view_new (0, 0, 130, 8, grav_northeast); hud_frags_view->draw = draw_frags; - } else if (vid.conwidth < 640) { + } else if (r_data->vid->conwidth < 640) { hud_view = view_new (0, 0, 512, 48, grav_south); minifrags_view = view_new (320, 0, 192, 48, grav_southwest); @@ -1894,7 +1896,7 @@ init_hud_views (void) if (miniteam_view) view_add (hud_view, miniteam_view); - view = view_new (0, 0, vid.conwidth, 48, grav_south); + view = view_new (0, 0, r_data->vid->conwidth, 48, grav_south); view_add (view, hud_view); hud_view = view; @@ -1907,10 +1909,11 @@ init_hud_views (void) static void init_views (void) { - if (vid.conheight > 300) + if (r_data->vid->conheight > 300) overlay_view = view_new (0, 0, 320, 300, grav_center); else - overlay_view = view_new (0, 0, 320, vid.conheight, grav_center); + overlay_view = view_new (0, 0, 320, r_data->vid->conheight, + grav_center); overlay_view->draw = draw_overlay; overlay_view->visible = 0; @@ -1943,78 +1946,85 @@ Sbar_Init (void) init_views (); for (i = 0; i < 10; i++) { - sb_nums[0][i] = Draw_PicFromWad (va ("num_%i", i)); - sb_nums[1][i] = Draw_PicFromWad (va ("anum_%i", i)); + sb_nums[0][i] = r_funcs->Draw_PicFromWad (va ("num_%i", i)); + sb_nums[1][i] = r_funcs->Draw_PicFromWad (va ("anum_%i", i)); } - sb_nums[0][10] = Draw_PicFromWad ("num_minus"); - sb_nums[1][10] = Draw_PicFromWad ("anum_minus"); + sb_nums[0][10] = r_funcs->Draw_PicFromWad ("num_minus"); + sb_nums[1][10] = r_funcs->Draw_PicFromWad ("anum_minus"); - sb_colon = Draw_PicFromWad ("num_colon"); - sb_slash = Draw_PicFromWad ("num_slash"); + sb_colon = r_funcs->Draw_PicFromWad ("num_colon"); + sb_slash = r_funcs->Draw_PicFromWad ("num_slash"); - sb_weapons[0][0] = Draw_PicFromWad ("inv_shotgun"); - sb_weapons[0][1] = Draw_PicFromWad ("inv_sshotgun"); - sb_weapons[0][2] = Draw_PicFromWad ("inv_nailgun"); - sb_weapons[0][3] = Draw_PicFromWad ("inv_snailgun"); - sb_weapons[0][4] = Draw_PicFromWad ("inv_rlaunch"); - sb_weapons[0][5] = Draw_PicFromWad ("inv_srlaunch"); - sb_weapons[0][6] = Draw_PicFromWad ("inv_lightng"); + sb_weapons[0][0] = r_funcs->Draw_PicFromWad ("inv_shotgun"); + sb_weapons[0][1] = r_funcs->Draw_PicFromWad ("inv_sshotgun"); + sb_weapons[0][2] = r_funcs->Draw_PicFromWad ("inv_nailgun"); + sb_weapons[0][3] = r_funcs->Draw_PicFromWad ("inv_snailgun"); + sb_weapons[0][4] = r_funcs->Draw_PicFromWad ("inv_rlaunch"); + sb_weapons[0][5] = r_funcs->Draw_PicFromWad ("inv_srlaunch"); + sb_weapons[0][6] = r_funcs->Draw_PicFromWad ("inv_lightng"); - sb_weapons[1][0] = Draw_PicFromWad ("inv2_shotgun"); - sb_weapons[1][1] = Draw_PicFromWad ("inv2_sshotgun"); - sb_weapons[1][2] = Draw_PicFromWad ("inv2_nailgun"); - sb_weapons[1][3] = Draw_PicFromWad ("inv2_snailgun"); - sb_weapons[1][4] = Draw_PicFromWad ("inv2_rlaunch"); - sb_weapons[1][5] = Draw_PicFromWad ("inv2_srlaunch"); - sb_weapons[1][6] = Draw_PicFromWad ("inv2_lightng"); + sb_weapons[1][0] = r_funcs->Draw_PicFromWad ("inv2_shotgun"); + sb_weapons[1][1] = r_funcs->Draw_PicFromWad ("inv2_sshotgun"); + sb_weapons[1][2] = r_funcs->Draw_PicFromWad ("inv2_nailgun"); + sb_weapons[1][3] = r_funcs->Draw_PicFromWad ("inv2_snailgun"); + sb_weapons[1][4] = r_funcs->Draw_PicFromWad ("inv2_rlaunch"); + sb_weapons[1][5] = r_funcs->Draw_PicFromWad ("inv2_srlaunch"); + sb_weapons[1][6] = r_funcs->Draw_PicFromWad ("inv2_lightng"); for (i = 0; i < 5; i++) { - sb_weapons[2 + i][0] = Draw_PicFromWad (va ("inva%i_shotgun", i + 1)); - sb_weapons[2 + i][1] = Draw_PicFromWad (va ("inva%i_sshotgun", i + 1)); - sb_weapons[2 + i][2] = Draw_PicFromWad (va ("inva%i_nailgun", i + 1)); - sb_weapons[2 + i][3] = Draw_PicFromWad (va ("inva%i_snailgun", i + 1)); - sb_weapons[2 + i][4] = Draw_PicFromWad (va ("inva%i_rlaunch", i + 1)); - sb_weapons[2 + i][5] = Draw_PicFromWad (va ("inva%i_srlaunch", i + 1)); - sb_weapons[2 + i][6] = Draw_PicFromWad (va ("inva%i_lightng", i + 1)); + sb_weapons[2 + i][0] = r_funcs->Draw_PicFromWad (va ("inva%i_shotgun", + i + 1)); + sb_weapons[2 + i][1] = r_funcs->Draw_PicFromWad (va ("inva%i_sshotgun", + i + 1)); + sb_weapons[2 + i][2] = r_funcs->Draw_PicFromWad (va ("inva%i_nailgun", + i + 1)); + sb_weapons[2 + i][3] = r_funcs->Draw_PicFromWad (va ("inva%i_snailgun", + i + 1)); + sb_weapons[2 + i][4] = r_funcs->Draw_PicFromWad (va ("inva%i_rlaunch", + i + 1)); + sb_weapons[2 + i][5] = r_funcs->Draw_PicFromWad (va ("inva%i_srlaunch", + i + 1)); + sb_weapons[2 + i][6] = r_funcs->Draw_PicFromWad (va ("inva%i_lightng", + i + 1)); } - sb_ammo[0] = Draw_PicFromWad ("sb_shells"); - sb_ammo[1] = Draw_PicFromWad ("sb_nails"); - sb_ammo[2] = Draw_PicFromWad ("sb_rocket"); - sb_ammo[3] = Draw_PicFromWad ("sb_cells"); + sb_ammo[0] = r_funcs->Draw_PicFromWad ("sb_shells"); + sb_ammo[1] = r_funcs->Draw_PicFromWad ("sb_nails"); + sb_ammo[2] = r_funcs->Draw_PicFromWad ("sb_rocket"); + sb_ammo[3] = r_funcs->Draw_PicFromWad ("sb_cells"); - sb_armor[0] = Draw_PicFromWad ("sb_armor1"); - sb_armor[1] = Draw_PicFromWad ("sb_armor2"); - sb_armor[2] = Draw_PicFromWad ("sb_armor3"); + sb_armor[0] = r_funcs->Draw_PicFromWad ("sb_armor1"); + sb_armor[1] = r_funcs->Draw_PicFromWad ("sb_armor2"); + sb_armor[2] = r_funcs->Draw_PicFromWad ("sb_armor3"); - sb_items[0] = Draw_PicFromWad ("sb_key1"); - sb_items[1] = Draw_PicFromWad ("sb_key2"); - sb_items[2] = Draw_PicFromWad ("sb_invis"); - sb_items[3] = Draw_PicFromWad ("sb_invuln"); - sb_items[4] = Draw_PicFromWad ("sb_suit"); - sb_items[5] = Draw_PicFromWad ("sb_quad"); + sb_items[0] = r_funcs->Draw_PicFromWad ("sb_key1"); + sb_items[1] = r_funcs->Draw_PicFromWad ("sb_key2"); + sb_items[2] = r_funcs->Draw_PicFromWad ("sb_invis"); + sb_items[3] = r_funcs->Draw_PicFromWad ("sb_invuln"); + sb_items[4] = r_funcs->Draw_PicFromWad ("sb_suit"); + sb_items[5] = r_funcs->Draw_PicFromWad ("sb_quad"); - sb_sigil[0] = Draw_PicFromWad ("sb_sigil1"); - sb_sigil[1] = Draw_PicFromWad ("sb_sigil2"); - sb_sigil[2] = Draw_PicFromWad ("sb_sigil3"); - sb_sigil[3] = Draw_PicFromWad ("sb_sigil4"); + sb_sigil[0] = r_funcs->Draw_PicFromWad ("sb_sigil1"); + sb_sigil[1] = r_funcs->Draw_PicFromWad ("sb_sigil2"); + sb_sigil[2] = r_funcs->Draw_PicFromWad ("sb_sigil3"); + sb_sigil[3] = r_funcs->Draw_PicFromWad ("sb_sigil4"); - sb_faces[4][0] = Draw_PicFromWad ("face1"); - sb_faces[4][1] = Draw_PicFromWad ("face_p1"); - sb_faces[3][0] = Draw_PicFromWad ("face2"); - sb_faces[3][1] = Draw_PicFromWad ("face_p2"); - sb_faces[2][0] = Draw_PicFromWad ("face3"); - sb_faces[2][1] = Draw_PicFromWad ("face_p3"); - sb_faces[1][0] = Draw_PicFromWad ("face4"); - sb_faces[1][1] = Draw_PicFromWad ("face_p4"); - sb_faces[0][0] = Draw_PicFromWad ("face5"); - sb_faces[0][1] = Draw_PicFromWad ("face_p5"); + sb_faces[4][0] = r_funcs->Draw_PicFromWad ("face1"); + sb_faces[4][1] = r_funcs->Draw_PicFromWad ("face_p1"); + sb_faces[3][0] = r_funcs->Draw_PicFromWad ("face2"); + sb_faces[3][1] = r_funcs->Draw_PicFromWad ("face_p2"); + sb_faces[2][0] = r_funcs->Draw_PicFromWad ("face3"); + sb_faces[2][1] = r_funcs->Draw_PicFromWad ("face_p3"); + sb_faces[1][0] = r_funcs->Draw_PicFromWad ("face4"); + sb_faces[1][1] = r_funcs->Draw_PicFromWad ("face_p4"); + sb_faces[0][0] = r_funcs->Draw_PicFromWad ("face5"); + sb_faces[0][1] = r_funcs->Draw_PicFromWad ("face_p5"); - sb_face_invis = Draw_PicFromWad ("face_invis"); - sb_face_invuln = Draw_PicFromWad ("face_invul2"); - sb_face_invis_invuln = Draw_PicFromWad ("face_inv2"); - sb_face_quad = Draw_PicFromWad ("face_quad"); + sb_face_invis = r_funcs->Draw_PicFromWad ("face_invis"); + sb_face_invuln = r_funcs->Draw_PicFromWad ("face_invul2"); + sb_face_invis_invuln = r_funcs->Draw_PicFromWad ("face_inv2"); + sb_face_quad = r_funcs->Draw_PicFromWad ("face_quad"); Cmd_AddCommand ("+showscores", Sbar_ShowScores, "Display information on everyone playing"); @@ -2025,11 +2035,11 @@ Sbar_Init (void) Cmd_AddCommand ("-showteamscores", Sbar_DontShowTeamScores, "Stop displaying information for your team"); - sb_sbar = Draw_PicFromWad ("sbar"); - sb_ibar = Draw_PicFromWad ("ibar"); - sb_scorebar = Draw_PicFromWad ("scorebar"); + sb_sbar = r_funcs->Draw_PicFromWad ("sbar"); + sb_ibar = r_funcs->Draw_PicFromWad ("ibar"); + sb_scorebar = r_funcs->Draw_PicFromWad ("scorebar"); - r_viewsize_callback = viewsize_f; + r_data->viewsize_callback = viewsize_f; hud_scoreboard_uid = Cvar_Get ("hud_scoreboard_uid", "0", CVAR_NONE, Sbar_DMO_Init_f, "Set to 1 to show uid " @@ -2049,6 +2059,11 @@ Sbar_Init (void) "overlay: center, northwest, north, " "northeast, west, east, southwest, " "south, southeast"); + scr_centertime = Cvar_Get ("scr_centertime", "2", CVAR_NONE, NULL, "How " + "long in seconds screen hints are displayed"); + scr_printspeed = Cvar_Get ("scr_printspeed", "8", CVAR_NONE, NULL, + "How fast the text is displayed at the end of " + "the single player episodes"); // register GIB builtins GIB_Builtin_Add ("print::center", Sbar_GIB_Print_Center_f);