Modular rendering system. Patch by use.less01

This might break MSVC builds. I'll take care of it later
This commit is contained in:
Thilo Schulz 2011-08-01 01:19:55 +00:00
parent 8ab958fab9
commit 40dfcee06e
24 changed files with 335 additions and 186 deletions

View file

@ -1434,7 +1434,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;
@ -1463,12 +1463,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;
}

View file

@ -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;
}

View file

@ -1009,7 +1009,7 @@ void R_Register( void )
r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_mode = ri.Cvar_Get( "r_mode", "3", 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_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH );
r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH );
r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
@ -1129,6 +1129,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 );
}
/*
@ -1154,7 +1155,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 ) );
@ -1279,7 +1280,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();
}
}
@ -1291,7 +1292,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;

View file

@ -359,9 +359,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

View file

@ -1306,6 +1306,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

View file

@ -218,7 +218,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) {
}
flod *= tr.currentModel->numLods;
lod = Q_ftol(flod);
lod = ri.ftol(flod);
if ( lod < 0 )
{

View file

@ -278,7 +278,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;
}

View file

@ -131,8 +131,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 );
@ -141,6 +144,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) );
@ -160,12 +165,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

View file

@ -215,7 +215,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;
}

View file

@ -233,7 +233,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 ) {
@ -689,9 +689,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;
}

View file

@ -27,7 +27,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 )
{
@ -699,7 +699,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;
@ -1180,19 +1180,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;
}

View file

@ -2701,7 +2701,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;
}
@ -2735,7 +2735,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;
}
@ -2765,7 +2765,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;
}

View file

@ -553,10 +553,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;

View file

@ -547,7 +547,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))) ) {