summaryrefslogtreecommitdiff
path: root/src/renderergl1
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderergl1')
-rw-r--r--src/renderergl1/tr_backend.c2
-rw-r--r--src/renderergl1/tr_cmds.c21
-rw-r--r--src/renderergl1/tr_image.c10
-rw-r--r--src/renderergl1/tr_light.c8
-rw-r--r--src/renderergl1/tr_local.h14
-rw-r--r--src/renderergl1/tr_main.c22
-rw-r--r--src/renderergl1/tr_shader.c17
7 files changed, 60 insertions, 34 deletions
diff --git a/src/renderergl1/tr_backend.c b/src/renderergl1/tr_backend.c
index 18a033b6..7cd455e8 100644
--- a/src/renderergl1/tr_backend.c
+++ b/src/renderergl1/tr_backend.c
@@ -496,8 +496,6 @@ void RB_BeginDrawingView (void) {
}
-#define MAC_EVENT_PUMP_MSEC 5
-
/*
==================
RB_RenderDrawSurfList
diff --git a/src/renderergl1/tr_cmds.c b/src/renderergl1/tr_cmds.c
index 23aa9897..d92a8b94 100644
--- a/src/renderergl1/tr_cmds.c
+++ b/src/renderergl1/tr_cmds.c
@@ -115,20 +115,20 @@ void R_IssuePendingRenderCommands( void ) {
/*
============
-R_GetCommandBuffer
+R_GetCommandBufferReserved
make sure there is enough command space
============
*/
-void *R_GetCommandBuffer( int bytes ) {
+void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) {
renderCommandList_t *cmdList;
cmdList = &backEndData->commands;
bytes = PAD(bytes, sizeof(void *));
// always leave room for the end of list command
- if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) {
- if ( bytes > MAX_RENDER_COMMANDS - 4 ) {
+ if ( cmdList->used + bytes + sizeof( int ) + reservedBytes > MAX_RENDER_COMMANDS ) {
+ if ( bytes > MAX_RENDER_COMMANDS - sizeof( int ) ) {
ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes );
}
// if we run out of room, just start dropping commands
@@ -140,6 +140,17 @@ void *R_GetCommandBuffer( int bytes ) {
return cmdList->cmds + cmdList->used - bytes;
}
+/*
+=============
+R_GetCommandBuffer
+
+returns NULL if there is not enough space for important commands
+=============
+*/
+void *R_GetCommandBuffer( int bytes ) {
+ return R_GetCommandBufferReserved( bytes, PAD( sizeof( swapBuffersCommand_t ), sizeof(void *) ) );
+}
+
/*
=============
@@ -540,7 +551,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
if ( !tr.registered ) {
return;
}
- cmd = R_GetCommandBuffer( sizeof( *cmd ) );
+ cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
if ( !cmd ) {
return;
}
diff --git a/src/renderergl1/tr_image.c b/src/renderergl1/tr_image.c
index 6f58a5b2..2ed43ef0 100644
--- a/src/renderergl1/tr_image.c
+++ b/src/renderergl1/tr_image.c
@@ -558,6 +558,7 @@ static void Upload32( unsigned *data,
qboolean mipmap,
qboolean picmip,
qboolean lightMap,
+ qboolean allowCompression,
int *format,
int *pUploadWidth, int *pUploadHeight )
{
@@ -693,11 +694,11 @@ static void Upload32( unsigned *data,
}
else
{
- if ( glConfig.textureCompression == TC_S3TC_ARB )
+ if ( allowCompression && glConfig.textureCompression == TC_S3TC_ARB )
{
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
}
- else if ( glConfig.textureCompression == TC_S3TC )
+ else if ( allowCompression && glConfig.textureCompression == TC_S3TC )
{
internalFormat = GL_RGB4_S3TC;
}
@@ -893,6 +894,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
image->flags & IMGFLAG_MIPMAP,
image->flags & IMGFLAG_PICMIP,
isLightmap,
+ !(image->flags & IMGFLAG_NO_COMPRESSION),
&image->internalFormat,
&image->uploadWidth,
&image->uploadHeight );
@@ -1556,7 +1558,7 @@ qhandle_t RE_RegisterSkin( const char *name ) {
// If not a .skin file, load as a single shader
if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) {
skin->numSurfaces = 1;
- skin->surfaces[0] = ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low );
+ skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue );
return hSkin;
}
@@ -1627,7 +1629,7 @@ void R_InitSkins( void ) {
skin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low );
Q_strncpyz( skin->name, "<default skin>", sizeof( skin->name ) );
skin->numSurfaces = 1;
- skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low );
+ skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low );
skin->surfaces[0]->shader = tr.defaultShader;
}
diff --git a/src/renderergl1/tr_light.c b/src/renderergl1/tr_light.c
index 779451f1..35233739 100644
--- a/src/renderergl1/tr_light.c
+++ b/src/renderergl1/tr_light.c
@@ -152,7 +152,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
frac[i] = v - pos[i];
if ( pos[i] < 0 ) {
pos[i] = 0;
- } else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) {
+ } else if ( pos[i] > tr.world->lightGridBounds[i] - 1 ) {
pos[i] = tr.world->lightGridBounds[i] - 1;
}
}
@@ -183,6 +183,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
data = gridData;
for ( j = 0 ; j < 3 ; j++ ) {
if ( i & (1<<j) ) {
+ if ( pos[j] + 1 > tr.world->lightGridBounds[j] - 1 ) {
+ break; // ignore values outside lightgrid
+ }
factor *= frac[j];
data += gridStep[j];
} else {
@@ -190,6 +193,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
}
}
+ if ( j != 3 ) {
+ continue;
+ }
if ( !(data[0]+data[1]+data[2]) ) {
continue; // ignore samples in walls
}
diff --git a/src/renderergl1/tr_local.h b/src/renderergl1/tr_local.h
index 6264af82..0d8131ec 100644
--- a/src/renderergl1/tr_local.h
+++ b/src/renderergl1/tr_local.h
@@ -1406,20 +1406,6 @@ int R_IQMLerpTag( orientation_t *tag, iqmData_t *data,
/*
=============================================================
-
-IMAGE LOADERS
-
-=============================================================
-*/
-
-void R_LoadBMP( const char *name, byte **pic, int *width, int *height );
-void R_LoadJPG( const char *name, byte **pic, int *width, int *height );
-void R_LoadPCX( const char *name, byte **pic, int *width, int *height );
-void R_LoadPNG( const char *name, byte **pic, int *width, int *height );
-void R_LoadTGA( const char *name, byte **pic, int *width, int *height );
-
-/*
-=============================================================
=============================================================
*/
void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,
diff --git a/src/renderergl1/tr_main.c b/src/renderergl1/tr_main.c
index 500bb788..7df28230 100644
--- a/src/renderergl1/tr_main.c
+++ b/src/renderergl1/tr_main.c
@@ -1012,6 +1012,10 @@ int R_SpriteFogNum( trRefEntity_t *ent ) {
return 0;
}
+ if ( ent->e.renderfx & RF_CROSSHAIR ) {
+ return 0;
+ }
+
for ( i = 1 ; i < tr.world->numfogs ; i++ ) {
fog = &tr.world->fogs[i];
for ( j = 0 ; j < 3 ; j++ ) {
@@ -1143,13 +1147,6 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) {
return;
}
- // if we overflowed MAX_DRAWSURFS, the drawsurfs
- // wrapped around in the buffer and we will be missing
- // the first surfaces, not the last ones
- if ( numDrawSurfs > MAX_DRAWSURFS ) {
- numDrawSurfs = MAX_DRAWSURFS;
- }
-
// sort the drawsurfs by sort type, then orientation, then shader
R_RadixSort( drawSurfs, numDrawSurfs );
@@ -1358,6 +1355,7 @@ or a mirror / remote location
*/
void R_RenderView (viewParms_t *parms) {
int firstDrawSurf;
+ int numDrawSurfs;
if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) {
return;
@@ -1380,7 +1378,15 @@ void R_RenderView (viewParms_t *parms) {
R_GenerateDrawSurfs();
- R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );
+ // if we overflowed MAX_DRAWSURFS, the drawsurfs
+ // wrapped around in the buffer and we will be missing
+ // the first surfaces, not the last ones
+ numDrawSurfs = tr.refdef.numDrawSurfs;
+ if ( numDrawSurfs > MAX_DRAWSURFS ) {
+ numDrawSurfs = MAX_DRAWSURFS;
+ }
+
+ R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf );
// draw main system development information (surface outlines, etc)
R_DebugGraphics();
diff --git a/src/renderergl1/tr_shader.c b/src/renderergl1/tr_shader.c
index 2a66afd0..34d6d64e 100644
--- a/src/renderergl1/tr_shader.c
+++ b/src/renderergl1/tr_shader.c
@@ -1569,6 +1569,23 @@ static qboolean ParseShader( char **text )
return qfalse;
}
+ if ( r_greyscale->integer )
+ {
+ float luminance;
+
+ luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] );
+ VectorSet( shader.fogParms.color, luminance, luminance, luminance );
+ }
+ else if ( r_greyscale->value )
+ {
+ float luminance;
+
+ luminance = LUMA( shader.fogParms.color[0], shader.fogParms.color[1], shader.fogParms.color[2] );
+ shader.fogParms.color[0] = LERP( shader.fogParms.color[0], luminance, r_greyscale->value );
+ shader.fogParms.color[1] = LERP( shader.fogParms.color[1], luminance, r_greyscale->value );
+ shader.fogParms.color[2] = LERP( shader.fogParms.color[2], luminance, r_greyscale->value );
+ }
+
token = COM_ParseExt( text, qfalse );
if ( !token[0] )
{