diff options
author | Thilo Schulz <arny@ats.s.bawue.de> | 2011-08-01 01:19:55 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-10 23:11:05 +0000 |
commit | 819546192265e70832c75cecc29dce929a4feeec (patch) | |
tree | a345b3d876d8dbdcccf1b13ff450fe0227bf2176 /src | |
parent | 500076c2e63329331c2a98e88cfa34f8044a7b76 (diff) |
Modular rendering system. Patch by use.less01 This might break MSVC builds. I'll take care of it later
Diffstat (limited to 'src')
-rw-r--r-- | src/client/cl_cin.c | 4 | ||||
-rw-r--r-- | src/client/cl_main.c | 56 | ||||
-rw-r--r-- | src/client/cl_scrn.c | 4 | ||||
-rw-r--r-- | src/qcommon/common.c | 31 | ||||
-rw-r--r-- | src/qcommon/q_math.c | 29 | ||||
-rw-r--r-- | src/qcommon/q_platform.h | 8 | ||||
-rw-r--r-- | src/renderer/tr_image.c | 6 | ||||
-rw-r--r-- | src/renderer/tr_image_png.c | 2 | ||||
-rw-r--r-- | src/renderer/tr_init.c | 12 | ||||
-rw-r--r-- | src/renderer/tr_light.c | 6 | ||||
-rw-r--r-- | src/renderer/tr_local.h | 1 | ||||
-rw-r--r-- | src/renderer/tr_mesh.c | 2 | ||||
-rw-r--r-- | src/renderer/tr_model.c | 2 | ||||
-rw-r--r-- | src/renderer/tr_public.h | 23 | ||||
-rw-r--r-- | src/renderer/tr_scene.c | 2 | ||||
-rw-r--r-- | src/renderer/tr_shade.c | 8 | ||||
-rw-r--r-- | src/renderer/tr_shade_calc.c | 10 | ||||
-rw-r--r-- | src/renderer/tr_shader.c | 6 | ||||
-rw-r--r-- | src/renderer/tr_sky.c | 8 | ||||
-rw-r--r-- | src/renderer/tr_world.c | 2 | ||||
-rw-r--r-- | src/sdl/sdl_gamma.c | 2 | ||||
-rw-r--r-- | src/sdl/sdl_glimp.c | 22 | ||||
-rw-r--r-- | src/sdl/sdl_input.c | 12 |
23 files changed, 172 insertions, 86 deletions
diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c index 8f6e82a2..3e0f55c7 100644 --- a/src/client/cl_cin.c +++ b/src/client/cl_cin.c @@ -53,8 +53,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_VIDEO_HANDLES 16 -extern glconfig_t glConfig; - static void RoQ_init( void ); @@ -992,7 +990,7 @@ static void readQuadInfo( byte *qData ) cinTable[currentHandle].drawY = cinTable[currentHandle].CIN_HEIGHT; // rage pro is very slow at 512 wide textures, voodoo can't do it at all - if ( glConfig.hardwareType == GLHW_RAGEPRO || glConfig.maxTextureSize <= 256) { + if ( cls.glconfig.hardwareType == GLHW_RAGEPRO || cls.glconfig.maxTextureSize <= 256) { if (cinTable[currentHandle].drawX>256) { cinTable[currentHandle].drawX = 256; } diff --git a/src/client/cl_main.c b/src/client/cl_main.c index a10b1444..3ffa0007 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -25,6 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include <limits.h> +#include "../sys/sys_local.h" +#include "../sys/sys_loadlib.h" + #ifdef USE_MUMBLE #include "libmumblelink.h" #endif @@ -45,6 +48,8 @@ cvar_t *cl_voipShowMeter; cvar_t *cl_voip; #endif +cvar_t *cl_renderer; + cvar_t *cl_nodelta; cvar_t *cl_debugMove; @@ -118,6 +123,9 @@ vm_t *cgvm; // Structure containing functions exported from refresh DLL refexport_t re; +#ifdef USE_RENDERER_DLOPEN +static void *rendererLib = NULL; +#endif ping_t cl_pinglist[MAX_PINGREQUESTS]; @@ -138,7 +146,6 @@ int serverStatusCount; void hA3Dg_ExportRenderGeom (refexport_t *incoming_re); #endif -extern void GLimp_Minimize(void); extern void SV_BotFrame( int time ); void CL_CheckForResend( void ); void CL_ShowIP_f(void); @@ -3238,9 +3245,39 @@ CL_InitRef void CL_InitRef( void ) { refimport_t ri; refexport_t *ret; +#ifdef USE_RENDERER_DLOPEN + GetRefAPI_t GetRefAPI; + char dllName[MAX_OSPATH]; +#endif Com_Printf( "----- Initializing Renderer ----\n" ); +#ifdef USE_RENDERER_DLOPEN + cl_renderer = Cvar_Get("cl_renderer", "opengl1", CVAR_ARCHIVE | CVAR_LATCH); + + Com_sprintf(dllName, sizeof(dllName), "renderer_%s_" ARCH_STRING DLL_EXT, cl_renderer->string); + + if(!(rendererLib = Sys_LoadDll(dllName)) && strcmp(cl_renderer->string, cl_renderer->resetString)) + { + Cvar_ForceReset("cl_renderer"); + + Com_sprintf(dllName, sizeof(dllName), "renderer_opengl1_" ARCH_STRING DLL_EXT); + rendererLib = Sys_LoadLibrary(dllName); + } + + if(!rendererLib) + { + Com_Printf("failed:\n\"%s\"\n", Sys_LibraryError()); + Com_Error(ERR_FATAL, "Failed to load renderer"); + } + + GetRefAPI = Sys_LoadFunction(rendererLib, "GetRefAPI"); + if(!GetRefAPI) + { + Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError()); + } +#endif + ri.Cmd_AddCommand = Cmd_AddCommand; ri.Cmd_RemoveCommand = Cmd_RemoveCommand; ri.Cmd_Argc = Cmd_Argc; @@ -3258,7 +3295,10 @@ void CL_InitRef( void ) { #endif ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory; ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory; + + ri.CM_ClusterPVS = CM_ClusterPVS; ri.CM_DrawDebugSurface = CM_DrawDebugSurface; + ri.FS_ReadFile = FS_ReadFile; ri.FS_FreeFile = FS_FreeFile; ri.FS_WriteFile = FS_WriteFile; @@ -3268,7 +3308,9 @@ void CL_InitRef( void ) { ri.FS_FileExists = FS_FileExists; ri.Cvar_Get = Cvar_Get; ri.Cvar_Set = Cvar_Set; + ri.Cvar_SetValue = Cvar_SetValue; ri.Cvar_CheckRange = Cvar_CheckRange; + ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; // cinematic stuff @@ -3278,6 +3320,17 @@ void CL_InitRef( void ) { ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; + ri.IN_Init = IN_Init; + ri.IN_Shutdown = IN_Shutdown; + ri.IN_Restart = IN_Restart; + + ri.ftol = Q_ftol; + + ri.Sys_SetEnv = Sys_SetEnv; + ri.Sys_GLimpSafeInit = Sys_GLimpSafeInit; + ri.Sys_GLimpInit = Sys_GLimpInit; + ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; + ret = GetRefAPI( REF_API_VERSION, &ri ); #if defined __USEA3D && defined __A3D_GEOM @@ -3619,7 +3672,6 @@ void CL_Init( void ) { Cmd_AddCommand ("model", CL_SetModel_f ); Cmd_AddCommand ("video", CL_Video_f ); Cmd_AddCommand ("stopvideo", CL_StopVideo_f ); - Cmd_AddCommand("minimize", GLimp_Minimize); CL_InitRef(); SCR_Init (); diff --git a/src/client/cl_scrn.c b/src/client/cl_scrn.c index 1a7a34b4..cd1252e1 100644 --- a/src/client/cl_scrn.c +++ b/src/client/cl_scrn.c @@ -545,9 +545,9 @@ void SCR_UpdateScreen( void ) { if( uivm || com_dedicated->integer ) { // XXX - extern cvar_t* r_anaglyphMode; + int in_anaglyphMode = Cvar_VariableIntegerValue("r_anaglyphMode"); // if running in stereo, we need to draw the frame twice - if ( cls.glconfig.stereoEnabled || r_anaglyphMode->integer) { + if ( cls.glconfig.stereoEnabled || in_anaglyphMode) { SCR_DrawScreenField( STEREO_LEFT ); SCR_DrawScreenField( STEREO_RIGHT ); } else { diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 5589b384..01183da0 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -3108,37 +3108,6 @@ void Com_Shutdown (void) { } -//------------------------------------------------------------------------ - - -/* -===================== -Q_acos - -the msvc acos doesn't always return a value between -PI and PI: - -int i; -i = 1065353246; -acos(*(float*) &i) == -1.#IND0 - - This should go in q_math but it is too late to add new traps - to game and ui -===================== -*/ -float Q_acos(float c) { - float angle; - - angle = acos(c); - - if (angle > M_PI) { - return (float)M_PI; - } - if (angle < -M_PI) { - return (float)M_PI; - } - return angle; -} - /* =========================================== command line completion diff --git a/src/qcommon/q_math.c b/src/qcommon/q_math.c index 7a480510..be06f226 100644 --- a/src/qcommon/q_math.c +++ b/src/qcommon/q_math.c @@ -1297,3 +1297,32 @@ int Q_isnan( float x ) return (int)( (unsigned int)fi.ui >> 31 ); } +//------------------------------------------------------------------------ + +#ifndef Q3_VM +/* +===================== +Q_acos + +the msvc acos doesn't always return a value between -PI and PI: + +int i; +i = 1065353246; +acos(*(float*) &i) == -1.#IND0 + +===================== +*/ +float Q_acos(float c) { + float angle; + + angle = acos(c); + + if (angle > M_PI) { + return (float)M_PI; + } + if (angle < -M_PI) { + return (float)M_PI; + } + return angle; +} +#endif diff --git a/src/qcommon/q_platform.h b/src/qcommon/q_platform.h index f4335489..e29fb396 100644 --- a/src/qcommon/q_platform.h +++ b/src/qcommon/q_platform.h @@ -74,6 +74,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // for windows fastcall option #define QDECL +#define QCALL //================================================================= WIN64/32 === @@ -85,6 +86,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #undef QDECL #define QDECL __cdecl +#undef QCALL +#define QCALL __stdcall + #if defined( _MSC_VER ) #define OS_STRING "win_msvc64" #elif defined __MINGW64__ @@ -109,6 +113,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #undef QDECL #define QDECL __cdecl +#undef QCALL +#define QCALL __stdcall + #if defined( _MSC_VER ) #define OS_STRING "win_msvc" #elif defined __MINGW32__ @@ -130,6 +137,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif + //============================================================== MAC OS X === #if defined(MACOS_X) || defined(__APPLE_CC__) diff --git a/src/renderer/tr_image.c b/src/renderer/tr_image.c index 136daf5f..a8b1a3be 100644 --- a/src/renderer/tr_image.c +++ b/src/renderer/tr_image.c @@ -1435,7 +1435,7 @@ static char *CommaParse( char **data_p ) { if (len == MAX_TOKEN_CHARS) { -// Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); +// ri.Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); len = 0; } com_token[len] = 0; @@ -1464,12 +1464,12 @@ qhandle_t RE_RegisterSkin( const char *name ) { char surfName[MAX_QPATH]; if ( !name || !name[0] ) { - Com_Printf( "Empty name passed to RE_RegisterSkin\n" ); + ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); return 0; } if ( strlen( name ) >= MAX_QPATH ) { - Com_Printf( "Skin name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); return 0; } diff --git a/src/renderer/tr_image_png.c b/src/renderer/tr_image_png.c index 8b65f758..4dc9d9bb 100644 --- a/src/renderer/tr_image_png.c +++ b/src/renderer/tr_image_png.c @@ -2063,7 +2063,7 @@ void R_LoadPNG(const char *name, byte **pic, int *width, int *height) { CloseBufferedFile(ThePNG); - Com_Printf(S_COLOR_YELLOW "%s: invalid image size\n", name); + ri.Printf( PRINT_WARNING, "%s: invalid image size\n", name ); return; } diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c index 7715cd7f..6819b030 100644 --- a/src/renderer/tr_init.c +++ b/src/renderer/tr_init.c @@ -1021,7 +1021,7 @@ void R_Register( void ) r_overBrightBits = ri.Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); r_fullscreen = ri.Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); - r_noborder = Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); + r_noborder = ri.Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); r_width = ri.Cvar_Get( "r_width", "640", CVAR_ARCHIVE | CVAR_LATCH ); r_height = ri.Cvar_Get( "r_height", "480", CVAR_ARCHIVE | CVAR_LATCH ); r_pixelAspect = ri.Cvar_Get( "r_pixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1141,6 +1141,7 @@ void R_Register( void ) ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f ); ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); + ri.Cmd_AddCommand( "minimize", GLimp_Minimize ); } /* @@ -1163,7 +1164,7 @@ void R_Init( void ) { // Swap_Init(); if ( (intptr_t)tess.xyz & 15 ) { - Com_Printf( "WARNING: tess.xyz not 16 byte aligned\n" ); + ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); } Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); @@ -1288,7 +1289,7 @@ Touch all images to make sure they are resident */ void RE_EndRegistration( void ) { R_SyncRenderThread(); - if (!Sys_LowPhysicalMemory()) { + if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } } @@ -1300,7 +1301,12 @@ GetRefAPI @@@@@@@@@@@@@@@@@@@@@ */ +#ifdef USE_RENDERER_DLOPEN +Q_EXPORT refexport_t QDECL *GetRefAPI ( int apiVersion, refimport_t *rimp ) { +#else refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { +#endif + static refexport_t re; ri = *rimp; diff --git a/src/renderer/tr_light.c b/src/renderer/tr_light.c index 05aca8b8..78441bb7 100644 --- a/src/renderer/tr_light.c +++ b/src/renderer/tr_light.c @@ -360,9 +360,9 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // save out the byte packet version - ((byte *)&ent->ambientLightInt)[0] = Q_ftol(ent->ambientLight[0]); - ((byte *)&ent->ambientLightInt)[1] = Q_ftol(ent->ambientLight[1]); - ((byte *)&ent->ambientLightInt)[2] = Q_ftol(ent->ambientLight[2]); + ((byte *)&ent->ambientLightInt)[0] = ri.ftol(ent->ambientLight[0]); + ((byte *)&ent->ambientLightInt)[1] = ri.ftol(ent->ambientLight[1]); + ((byte *)&ent->ambientLightInt)[2] = ri.ftol(ent->ambientLight[2]); ((byte *)&ent->ambientLightInt)[3] = 0xff; // transform the direction to local space diff --git a/src/renderer/tr_local.h b/src/renderer/tr_local.h index fe7a4ba5..b15a2b0e 100644 --- a/src/renderer/tr_local.h +++ b/src/renderer/tr_local.h @@ -1304,6 +1304,7 @@ void GLimp_FrontEndSleep( void ); void GLimp_WakeRenderer( void *data ); void GLimp_LogComment( char *comment ); +void GLimp_Minimize(void); // NOTE TTimo linux works with float gamma value, not the gamma table // the params won't be used, getting the r_gamma cvar directly diff --git a/src/renderer/tr_mesh.c b/src/renderer/tr_mesh.c index 446ee836..effbae01 100644 --- a/src/renderer/tr_mesh.c +++ b/src/renderer/tr_mesh.c @@ -219,7 +219,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { } flod *= tr.currentModel->numLods; - lod = Q_ftol(flod); + lod = ri.ftol(flod); if ( lod < 0 ) { diff --git a/src/renderer/tr_model.c b/src/renderer/tr_model.c index ce0bbdf7..b79fd458 100644 --- a/src/renderer/tr_model.c +++ b/src/renderer/tr_model.c @@ -279,7 +279,7 @@ qhandle_t RE_RegisterModel( const char *name ) { } if ( strlen( name ) >= MAX_QPATH ) { - Com_Printf( "Model name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); return 0; } diff --git a/src/renderer/tr_public.h b/src/renderer/tr_public.h index fd2e4c05..d95a0023 100644 --- a/src/renderer/tr_public.h +++ b/src/renderer/tr_public.h @@ -133,8 +133,11 @@ typedef struct { cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags ); void (*Cvar_Set)( const char *name, const char *value ); + void (*Cvar_SetValue) (const char *name, float value); void (*Cvar_CheckRange)( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral ); + int (*Cvar_VariableIntegerValue) (const char *var_name); + void (*Cmd_AddCommand)( const char *name, void(*cmd)(void) ); void (*Cmd_RemoveCommand)( const char *name ); @@ -143,6 +146,8 @@ typedef struct { void (*Cmd_ExecuteText) (int exec_when, const char *text); + byte *(*CM_ClusterPVS)(int cluster); + // visualization for debugging collision detection void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) ); @@ -162,12 +167,30 @@ typedef struct { e_status (*CIN_RunCinematic) (int handle); void (*CL_WriteAVIVideoFrame)( const byte *buffer, int size ); + + // input event handling + void (*IN_Init)( void ); + void (*IN_Shutdown)( void ); + void (*IN_Restart)( void ); + + // math + long (*ftol)(float f); + + // system stuff + void (*Sys_SetEnv)( const char *name, const char *value ); + void (*Sys_GLimpSafeInit)( void ); + void (*Sys_GLimpInit)( void ); + qboolean (*Sys_LowPhysicalMemory)( void ); } refimport_t; // this is the only function actually exported at the linker level // If the module can't init to a valid rendering state, NULL will be // returned. +#ifdef USE_RENDERER_DLOPEN +typedef refexport_t* (QDECL *GetRefAPI_t) (int apiVersion, refimport_t * rimp); +#else refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp ); +#endif #endif // __TR_PUBLIC_H diff --git a/src/renderer/tr_scene.c b/src/renderer/tr_scene.c index 232cb684..f7483e8f 100644 --- a/src/renderer/tr_scene.c +++ b/src/renderer/tr_scene.c @@ -216,7 +216,7 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { static qboolean firstTime = qtrue; if (firstTime) { firstTime = qfalse; - Com_DPrintf(S_COLOR_YELLOW "WARNING: RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); + ri.Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); } return; } diff --git a/src/renderer/tr_shade.c b/src/renderer/tr_shade.c index c71a8d34..b8e8d268 100644 --- a/src/renderer/tr_shade.c +++ b/src/renderer/tr_shade.c @@ -234,7 +234,7 @@ static void R_BindAnimatedImage( textureBundle_t *bundle ) { // it is necessary to do this messy calc to make sure animations line up // exactly with waveforms of the same frequency - index = Q_ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); + index = ri.ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); index >>= FUNCTABLE_SIZE2; if ( index < 0 ) { @@ -690,9 +690,9 @@ static void ProjectDlightTexture_scalar( void ) { } } clipBits[i] = clip; - colors[0] = Q_ftol(floatColor[0] * modulate); - colors[1] = Q_ftol(floatColor[1] * modulate); - colors[2] = Q_ftol(floatColor[2] * modulate); + colors[0] = ri.ftol(floatColor[0] * modulate); + colors[1] = ri.ftol(floatColor[1] * modulate); + colors[2] = ri.ftol(floatColor[2] * modulate); colors[3] = 255; } diff --git a/src/renderer/tr_shade_calc.c b/src/renderer/tr_shade_calc.c index a88aac9f..58ec6f45 100644 --- a/src/renderer/tr_shade_calc.c +++ b/src/renderer/tr_shade_calc.c @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif -#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ Q_ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) +#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri.ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) static float *TableForFunc( genFunc_t func ) { @@ -700,7 +700,7 @@ void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ) glow = 1; } - v = Q_ftol(255 * glow); + v = ri.ftol(255 * glow); color[0] = color[1] = color[2] = v; color[3] = 255; v = *(int *)color; @@ -1181,19 +1181,19 @@ static void RB_CalcDiffuseColor_scalar( unsigned char *colors ) *(int *)&colors[i*4] = ambientLightInt; continue; } - j = Q_ftol(ambientLight[0] + incoming * directedLight[0]); + j = ri.ftol(ambientLight[0] + incoming * directedLight[0]); if ( j > 255 ) { j = 255; } colors[i*4+0] = j; - j = Q_ftol(ambientLight[1] + incoming * directedLight[1]); + j = ri.ftol(ambientLight[1] + incoming * directedLight[1]); if ( j > 255 ) { j = 255; } colors[i*4+1] = j; - j = Q_ftol(ambientLight[2] + incoming * directedLight[2]); + j = ri.ftol(ambientLight[2] + incoming * directedLight[2]); if ( j > 255 ) { j = 255; } diff --git a/src/renderer/tr_shader.c b/src/renderer/tr_shader.c index 3152612a..2bbc3a12 100644 --- a/src/renderer/tr_shader.c +++ b/src/renderer/tr_shader.c @@ -2702,7 +2702,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - Com_Printf( "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -2736,7 +2736,7 @@ qhandle_t RE_RegisterShader( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - Com_Printf( "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -2766,7 +2766,7 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - Com_Printf( "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } diff --git a/src/renderer/tr_sky.c b/src/renderer/tr_sky.c index ffe84f50..3b90fdeb 100644 --- a/src/renderer/tr_sky.c +++ b/src/renderer/tr_sky.c @@ -554,10 +554,10 @@ static void FillCloudBox( const shader_t *shader, int stage ) continue; } - sky_mins_subd[0] = Q_ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); - sky_mins_subd[1] = Q_ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[0] = Q_ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[1] = Q_ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; diff --git a/src/renderer/tr_world.c b/src/renderer/tr_world.c index 8f91285e..85a0043f 100644 --- a/src/renderer/tr_world.c +++ b/src/renderer/tr_world.c @@ -548,7 +548,7 @@ qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) { byte *vis; leaf = R_PointInLeaf( p1 ); - vis = CM_ClusterPVS( leaf->cluster ); + vis = ri.CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? leaf = R_PointInLeaf( p2 ); if ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) { diff --git a/src/sdl/sdl_gamma.c b/src/sdl/sdl_gamma.c index dad4bb34..7f16b606 100644 --- a/src/sdl/sdl_gamma.c +++ b/src/sdl/sdl_gamma.c @@ -61,7 +61,7 @@ void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned GetVersionEx( &vinfo ); if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) { - Com_DPrintf( "performing gamma clamp.\n" ); + ri.Printf( PRINT_DEVELOPER, "performing gamma clamp.\n" ); for( j = 0 ; j < 3 ; j++ ) { for( i = 0 ; i < 128 ; i++ ) diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index 41114ca9..babbaade 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -93,7 +93,7 @@ void GLimp_Shutdown( void ) { float oldDisplayAspect = glConfig.displayAspect; - IN_Shutdown(); + ri.IN_Shutdown(); SDL_QuitSubSystem( SDL_INIT_VIDEO ); screen = NULL; @@ -484,10 +484,10 @@ static qboolean GLimp_StartDriverAndSetMode( qboolean failSafe, qboolean fullscr SDL_VideoDriverName( driverName, sizeof( driverName ) - 1 ); ri.Printf( PRINT_ALL, "SDL using driver \"%s\"\n", driverName ); - Cvar_Set( "r_sdlDriver", driverName ); + ri.Cvar_Set( "r_sdlDriver", driverName ); } - if (fullscreen && Cvar_VariableIntegerValue( "in_nograb" ) ) + if (fullscreen && ri.Cvar_VariableIntegerValue( "in_nograb" ) ) { ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n"); ri.Cvar_Set( "r_fullscreen", "0" ); @@ -704,7 +704,7 @@ void GLimp_Init( void ) r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE ); r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE ); - if( Cvar_VariableIntegerValue( "com_abnormalExit" ) ) + if( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) ) { ri.Cvar_Set( "r_width", va( "%d", R_FAILSAFE_WIDTH ) ); ri.Cvar_Set( "r_height", va( "%d", R_FAILSAFE_HEIGHT ) ); @@ -713,16 +713,16 @@ void GLimp_Init( void ) ri.Cvar_Set( "com_abnormalExit", "0" ); } - Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" ); + ri.Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" ); - Sys_GLimpInit( ); + ri.Sys_GLimpInit( ); // Create the window and set up the context if( GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer, r_noborder->integer ) ) goto success; // Try again, this time in a platform specific "safe mode" - Sys_GLimpSafeInit( ); + ri.Sys_GLimpSafeInit( ); if( GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer, qfalse ) ) goto success; @@ -760,7 +760,7 @@ success: ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here - IN_Init( ); + ri.IN_Init( ); } @@ -791,7 +791,7 @@ void GLimp_EndFrame( void ) // Find out the current state fullscreen = !!( s->flags & SDL_FULLSCREEN ); - if( r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ) ) + if( r_fullscreen->integer && ri.Cvar_VariableIntegerValue( "in_nograb" ) ) { ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n"); ri.Cvar_Set( "r_fullscreen", "0" ); @@ -809,9 +809,9 @@ void GLimp_EndFrame( void ) { // SDL_WM_ToggleFullScreen didn't work, so do it the slow way if( !sdlToggled ) - Cbuf_AddText( "vid_restart" ); + ri.Cmd_ExecuteText(EXEC_APPEND, "vid_restart"); - IN_Restart( ); + ri.IN_Restart( ); } r_fullscreen->modified = qfalse; diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c index 83b26086..2cc3dcf4 100644 --- a/src/sdl/sdl_input.c +++ b/src/sdl/sdl_input.c @@ -503,7 +503,7 @@ static void IN_ActivateMouse( void ) } // in_nograb makes no sense in fullscreen mode - if( !r_fullscreen->integer ) + if( !Cvar_VariableIntegerValue("r_fullscreen") ) { if( in_nograb->modified || !mouseActive ) { @@ -531,7 +531,7 @@ static void IN_DeactivateMouse( void ) // Always show the cursor when the mouse is disabled, // but not when fullscreen - if( !r_fullscreen->integer ) + if( !Cvar_VariableIntegerValue("r_fullscreen") ) { if( ( Key_GetCatcher( ) == KEYCATCH_UI ) && ( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS ) ) @@ -985,8 +985,8 @@ static void IN_ProcessEvents( void ) char width[32], height[32]; Com_sprintf( width, sizeof(width), "%d", e.resize.w ); Com_sprintf( height, sizeof(height), "%d", e.resize.h ); - ri.Cvar_Set( "r_width", width ); - ri.Cvar_Set( "r_height", height ); + Cvar_Set( "r_width", width ); + Cvar_Set( "r_height", height ); /* wait until user stops dragging for 1 second, so we aren't constantly recreating the GL context while he tries to drag...*/ @@ -1026,12 +1026,12 @@ void IN_Frame( void ) loading = !!( clc.state != CA_DISCONNECTED && clc.state != CA_ACTIVE ); cursorShowing = Key_GetCatcher( ) & KEYCATCH_UI; - if( !r_fullscreen->integer && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) + if( !Cvar_VariableIntegerValue("r_fullscreen") && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) { // Console is down in windowed mode IN_DeactivateMouse( ); } - else if( !r_fullscreen->integer && loading ) + else if( !Cvar_VariableIntegerValue("r_fullscreen") && loading ) { // Loading in windowed mode IN_DeactivateMouse( ); |