Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Formatting cleanup. Fix some memory leaks and uninitialized variables…

…. Fix extern const opStrings.
  • Loading branch information...
commit 8dc45f6bc81b2fab9eb7dc382ea961bf065b99b0 1 parent d291257
@DerSaidin DerSaidin authored
View
8 src/engine/rendererGL/tr_animation.cpp
@@ -711,7 +711,7 @@ qhandle_t RE_RegisterAnimation(const char *name)
skelAnimation_t *anim;
byte *buffer;
int bufferLen;
- qboolean loaded = qfalse;
+ qboolean loaded = qfalse;
if(!name || !name[0])
{
@@ -909,8 +909,8 @@ void R_AddMD5Surfaces(trRefEntity_t * ent)
md5Surface_t *surface;
shader_t *shader;
int i;
- bool personalModel;
- int fogNum;
+ bool personalModel;
+ int fogNum;
model = tr.currentModel->md5;
@@ -1048,7 +1048,7 @@ void R_AddMD5Interactions(trRefEntity_t * ent, trRefLight_t * light)
md5Model_t *model;
md5Surface_t *surface;
shader_t *shader = 0;
- bool personalModel;
+ bool personalModel;
byte cubeSideBits = CUBESIDE_CLIPALL;
interactionType_t iaType = IA_DEFAULT;
View
21 src/engine/rendererGL/tr_bsp.cpp
@@ -836,6 +836,7 @@ static void R_LoadLightmaps(lump_t * l, const char *bspName)
image = R_AllocImage(va("%s/%s", mapName, lightmapFiles[i]), qtrue);
if(!image) {
+ Com_Dealloc(hdrImage);
break;
}
@@ -5168,11 +5169,11 @@ static void R_LoadNodesAndLeafs(lump_t * nodeLump, lump_t * leafLump)
dleaf_t *inLeaf;
bspNode_t *out;
int numNodes, numLeafs;
- srfVert_t *verts;
- srfTriangle_t *triangles;
+ srfVert_t *verts = NULL;
+ srfTriangle_t *triangles = NULL;
IBO_t *volumeIBO;
- vec3_t mins, maxs;
-// vec3_t offset = {0.01, 0.01, 0.01};
+ vec3_t mins, maxs;
+// vec3_t offset = {0.01, 0.01, 0.01};
ri.Printf(PRINT_ALL, "...loading nodes and leaves\n");
@@ -5368,11 +5369,11 @@ static void R_LoadNodesAndLeafs(lump_t * nodeLump, lump_t * leafLump)
if(triangles)
{
- ri.Hunk_FreeTempMemory(triangles);
+ ri.Hunk_FreeTempMemory(triangles);
}
if(verts)
{
- ri.Hunk_FreeTempMemory(verts);
+ ri.Hunk_FreeTempMemory(verts);
}
tess.multiDrawPrimitives = 0;
@@ -5504,7 +5505,7 @@ static void R_LoadFogs(lump_t * l, lump_t * brushesLump, lump_t * sidesLump)
int planeNum;
shader_t *shader;
float d;
- int firstSide;
+ int firstSide = 0;
ri.Printf(PRINT_ALL, "...loading fogs\n");
@@ -6668,7 +6669,7 @@ R_PrecacheInteractionSurface
*/
static void R_PrecacheInteractionSurface(bspSurface_t * surf, trRefLight_t * light)
{
- bool intersects;
+ bool intersects;
if(surf->lightCount == s_lightCount)
{
@@ -7429,12 +7430,12 @@ static void R_CreateVBOShadowMeshes(trRefLight_t * light)
int numCaches;
shader_t *shader, *oldShader;
- bool alphaTest, oldAlphaTest;
+ bool alphaTest, oldAlphaTest;
bspSurface_t *surface;
srfVBOMesh_t *vboSurf;
- vec3_t bounds[2];
+ vec3_t bounds[2];
if(!r_vboShadows->integer)
return;
View
2  src/engine/rendererGL/tr_image_dds.cpp
@@ -717,7 +717,7 @@ image_t *R_LoadDDSImageData(void *pImageData, const char *name, int bits,
break;
default:
- ri.Printf(PRINT_WARNING, "R_LoadDDSImage: unsupported FOURCC 0x%08x, \"%s\"\n",
+ ri.Printf(PRINT_WARNING, "R_LoadDDSImage: unsupported FOURCC 0x%16x, \"%s\"\n",
ddsd->u4.ddpfPixelFormat.dwFourCC, name);
goto ret_error;
}
View
114 src/engine/rendererGL/tr_init.cpp
@@ -45,6 +45,10 @@ cvar_t *r_glMajorVersion;
cvar_t *r_glMinorVersion;
cvar_t *r_glDebugProfile;
+#ifdef USE_GLSL_OPTIMIZER
+cvar_t *r_glslOptimizer;
+#endif
+
cvar_t *r_flares;
cvar_t *r_flareSize;
cvar_t *r_flareFade;
@@ -484,7 +488,8 @@ void GL_CheckErrors_(const char *fileName, int line)
/*
** R_GetModeInfo
*/
-typedef struct vidmode_s {
+typedef struct vidmode_s
+{
const char *description;
int width, height;
float pixelAspect; // pixel width / height
@@ -515,25 +520,32 @@ static const vidmode_t r_vidModes[] =
};
static const int s_numVidModes = ( sizeof( r_vidModes ) / sizeof( r_vidModes[ 0 ] ) );
-qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) {
+qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode )
+{
const vidmode_t *vm;
- if ( mode < -2 ) {
+ if ( mode < -2 )
+ {
return qfalse;
}
-
- if ( mode >= s_numVidModes ) {
+ if ( mode >= s_numVidModes )
+ {
return qfalse;
}
- if( mode == -2) {
+ if( mode == -2)
+ {
// Must set width and height to display size before calling this function!
*windowAspect = ( float ) *width / *height;
- } else if ( mode == -1 ) {
+ }
+ else if ( mode == -1 )
+ {
*width = r_customwidth->integer;
*height = r_customheight->integer;
*windowAspect = r_customaspect->value;
- } else {
+ }
+ else
+ {
vm = &r_vidModes[ mode ];
*width = vm->width;
@@ -547,12 +559,14 @@ qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode )
/*
** R_ModeList_f
*/
-static void R_ModeList_f( void ) {
+static void R_ModeList_f( void )
+{
int i;
ri.Printf( PRINT_ALL, "\n" );
- for ( i = 0; i < s_numVidModes; i++ ) {
+ for ( i = 0; i < s_numVidModes; i++ )
+ {
ri.Printf( PRINT_ALL, "Mode %-2d: %s\n", i, r_vidModes[ i ].description );
}
@@ -601,7 +615,7 @@ static byte *RB_ReadPixels(int x, int y, int width, int height, size_t offset)
paddedLineLen = PAD(lineLen, packAlign);
// Allocate a few more bytes so that we can choose an alignment we like
- buffer = (byte*)ri.Hunk_AllocateTempMemory(offset + paddedLineLen * height + packAlign - 1);
+ buffer = (byte*)ri.Hunk_AllocateTempMemory(offset + (paddedLineLen * height) + packAlign - 1);
pixels = (byte*)PADP(buffer + offset, packAlign);
glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
@@ -609,7 +623,7 @@ static byte *RB_ReadPixels(int x, int y, int width, int height, size_t offset)
// Drop alignment and line padding bytes
for(i = 0; i < height; ++i)
{
- memmove(buffer + offset + i * lineLen, pixels + i * paddedLineLen, lineLen);
+ memmove(buffer + offset + (i * lineLen), pixels + (i * paddedLineLen), lineLen);
}
#endif
@@ -623,20 +637,20 @@ R_TakeScreenshot
*/
static void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName)
{
- byte *buffer;
- int dataSize;
- byte *end, *p;
+ byte *buffer;
+ size_t dataSize;
+ byte *end, *p;
// with 18 bytes for the TGA file header
buffer = RB_ReadPixels(x, y, width, height, 18);
Com_Memset(buffer, 0, 18);
- buffer[2] = 2; // uncompressed type
+ buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
- buffer[16] = 24; // pixel size
+ buffer[16] = 24; // pixel size
dataSize = 3 * width * height;
@@ -649,7 +663,7 @@ static void RB_TakeScreenshot(int x, int y, int width, int height, char *fileNam
p[2] = temp;
}
- if(tr.overbrightBits > 0 && glConfig.deviceSupportsGamma)
+ if((tr.overbrightBits > 0) && glConfig.deviceSupportsGamma)
{
R_GammaCorrect(buffer + 18, dataSize);
}
@@ -661,14 +675,14 @@ static void RB_TakeScreenshot(int x, int y, int width, int height, char *fileNam
/*
==================
-R_TakeScreenshotJPEG
+RB_TakeScreenshotJPEG
==================
*/
static void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName)
{
byte *buffer = RB_ReadPixels(x, y, width, height, 0);
- if(tr.overbrightBits > 0 && glConfig.deviceSupportsGamma)
+ if((tr.overbrightBits > 0) && glConfig.deviceSupportsGamma)
{
R_GammaCorrect(buffer, 3 * width * height);
}
@@ -679,14 +693,14 @@ static void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fil
/*
==================
-R_TakeScreenshotPNG
+RB_TakeScreenshotPNG
==================
*/
static void RB_TakeScreenshotPNG(int x, int y, int width, int height, char *fileName)
{
byte *buffer = RB_ReadPixels(x, y, width, height, 0);
- if(tr.overbrightBits > 0 && glConfig.deviceSupportsGamma)
+ if((tr.overbrightBits > 0) && glConfig.deviceSupportsGamma)
{
R_GammaCorrect(buffer, 3 * width * height);
}
@@ -1351,6 +1365,10 @@ void R_Register(void)
r_glCoreProfile = ri.Cvar_Get("r_glCoreProfile", "", CVAR_LATCH);
r_glDebugProfile = ri.Cvar_Get("r_glDebugProfile", "", CVAR_LATCH);
+#ifdef USE_GLSL_OPTIMIZER
+ r_glslOptimizer = ri.Cvar_Get("r_glslOptimizer", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
+#endif
+
// latched and archived variables
r_ext_compressed_textures = ri.Cvar_Get("r_ext_compressed_textures", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_ext_occlusion_query = ri.Cvar_Get("r_ext_occlusion_query", "1", CVAR_CHEAT | CVAR_LATCH);
@@ -1396,7 +1414,7 @@ void R_Register(void)
r_compressDiffuseMaps = ri.Cvar_Get("r_compressDiffuseMaps", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_compressSpecularMaps = ri.Cvar_Get("r_compressSpecularMaps", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_compressNormalMaps = ri.Cvar_Get("r_compressNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH);
- r_heatHazeFix = ri.Cvar_Get("r_heatHazeFix", "0", CVAR_CHEAT);
+ r_heatHazeFix = ri.Cvar_Get("r_heatHazeFix", "0", CVAR_CHEAT | CVAR_SHADER);
r_noMarksOnTrisurfs = ri.Cvar_Get("r_noMarksOnTrisurfs", "1", CVAR_CHEAT);
r_recompileShaders = ri.Cvar_Get( "r_recompileShaders", "0", CVAR_ARCHIVE );
@@ -1405,7 +1423,7 @@ void R_Register(void)
r_wolfFog = ri.Cvar_Get("r_wolfFog", "1", CVAR_CHEAT);
r_noFog = ri.Cvar_Get("r_noFog", "0", CVAR_CHEAT);
#ifdef EXPERIMENTAL
- r_screenSpaceAmbientOcclusion = ri.Cvar_Get("r_screenSpaceAmbientOcclusion", "0", CVAR_ARCHIVE);
+ r_screenSpaceAmbientOcclusion = ri.Cvar_Get("r_screenSpaceAmbientOcclusion", "0", CVAR_ARCHIVE | CVAR_SHADER);
//AssertCvarRange(r_screenSpaceAmbientOcclusion, 0, 2, qtrue);
#endif
#ifdef EXPERIMENTAL
@@ -1439,15 +1457,15 @@ void R_Register(void)
r_singleShader = ri.Cvar_Get("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH);
r_stitchCurves = ri.Cvar_Get("r_stitchCurves", "1", CVAR_CHEAT | CVAR_LATCH);
- r_debugShadowMaps = ri.Cvar_Get( "r_debugShadowMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
+ r_debugShadowMaps = ri.Cvar_Get("r_debugShadowMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
r_shadowMapLuminanceAlpha = ri.Cvar_Get("r_shadowMapLuminanceAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_shadowMapLinearFilter = ri.Cvar_Get("r_shadowMapLinearFilter", "1", CVAR_CHEAT | CVAR_LATCH);
- r_lightBleedReduction = ri.Cvar_Get( "r_lightBleedReduction", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_overDarkeningFactor = ri.Cvar_Get( "r_overDarkeningFactor", "30.0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_shadowMapDepthScale = ri.Cvar_Get( "r_shadowMapDepthScale", "1.41", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
+ r_lightBleedReduction = ri.Cvar_Get("r_lightBleedReduction", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_overDarkeningFactor = ri.Cvar_Get("r_overDarkeningFactor", "30.0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_shadowMapDepthScale = ri.Cvar_Get("r_shadowMapDepthScale", "1.41", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
r_parallelShadowSplitWeight = ri.Cvar_Get("r_parallelShadowSplitWeight", "0.9", CVAR_CHEAT);
- r_parallelShadowSplits = ri.Cvar_Get( "r_parallelShadowSplits", "2", CVAR_LATCH | CVAR_SHADER );
+ r_parallelShadowSplits = ri.Cvar_Get("r_parallelShadowSplits", "2", CVAR_LATCH | CVAR_SHADER);
AssertCvarRange(r_parallelShadowSplits, 0, MAX_SHADOWMAPS -1, qtrue);
r_lightSpacePerspectiveWarping = ri.Cvar_Get("r_lightSpacePerspectiveWarping", "1", CVAR_CHEAT);
@@ -1511,17 +1529,17 @@ void R_Register(void)
r_hdrMinLuminance = ri.Cvar_Get("r_hdrMinLuminance", "0.18", CVAR_CHEAT);
r_hdrMaxLuminance = ri.Cvar_Get("r_hdrMaxLuminance", "3000", CVAR_CHEAT);
r_hdrKey = ri.Cvar_Get("r_hdrKey", "0.28", CVAR_CHEAT);
- r_hdrContrastThreshold = ri.Cvar_Get("r_hdrContrastThreshold", "1.3", CVAR_CHEAT);
- r_hdrContrastOffset = ri.Cvar_Get("r_hdrContrastOffset", "3.0", CVAR_CHEAT);
+ r_hdrContrastThreshold = ri.Cvar_Get("r_hdrContrastThreshold", "1.3", CVAR_CHEAT | CVAR_SHADER);
+ r_hdrContrastOffset = ri.Cvar_Get("r_hdrContrastOffset", "3.0", CVAR_CHEAT | CVAR_SHADER);
r_hdrLightmap = ri.Cvar_Get("r_hdrLightmap", "1", CVAR_CHEAT | CVAR_LATCH);
r_hdrLightmapExposure = ri.Cvar_Get("r_hdrLightmapExposure", "1.0", CVAR_CHEAT | CVAR_LATCH);
r_hdrLightmapGamma = ri.Cvar_Get("r_hdrLightmapGamma", "1.7", CVAR_CHEAT | CVAR_LATCH);
r_hdrLightmapCompensate = ri.Cvar_Get("r_hdrLightmapCompensate", "1.0", CVAR_CHEAT | CVAR_LATCH);
- r_hdrToneMappingOperator = ri.Cvar_Get("r_hdrToneMappingOperator", "1", CVAR_CHEAT);
- r_hdrGamma = ri.Cvar_Get("r_hdrGamma", "1.1", CVAR_CHEAT);
+ r_hdrToneMappingOperator = ri.Cvar_Get("r_hdrToneMappingOperator", "1", CVAR_CHEAT | CVAR_SHADER);
+ r_hdrGamma = ri.Cvar_Get("r_hdrGamma", "1.1", CVAR_CHEAT | CVAR_SHADER);
r_hdrDebug = ri.Cvar_Get("r_hdrDebug", "0", CVAR_CHEAT);
- r_evsmPostProcess = ri.Cvar_Get("r_evsmPostProcess", "0", CVAR_ARCHIVE | CVAR_LATCH);
+ r_evsmPostProcess = ri.Cvar_Get("r_evsmPostProcess", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
r_printShaders = ri.Cvar_Get("r_printShaders", "0", CVAR_ARCHIVE);
@@ -1580,16 +1598,16 @@ void R_Register(void)
r_offsetFactor = ri.Cvar_Get("r_offsetFactor", "-1", CVAR_CHEAT);
r_offsetUnits = ri.Cvar_Get("r_offsetUnits", "-2", CVAR_CHEAT);
r_forceSpecular = ri.Cvar_Get("r_forceSpecular", "0", CVAR_CHEAT);
- r_specularExponent = ri.Cvar_Get( "r_specularExponent", "16", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_specularExponent2 = ri.Cvar_Get( "r_specularExponent2", "3", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_specularScale = ri.Cvar_Get( "r_specularScale", "1.4", CVAR_CHEAT );
- r_normalScale = ri.Cvar_Get( "r_normalScale", "1.1", CVAR_CHEAT );
- r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER );
+ r_specularExponent = ri.Cvar_Get("r_specularExponent", "16", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_specularExponent2 = ri.Cvar_Get("r_specularExponent2", "3", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_specularScale = ri.Cvar_Get("r_specularScale", "1.4", CVAR_CHEAT);
+ r_normalScale = ri.Cvar_Get("r_normalScale", "1.1", CVAR_CHEAT);
+ r_normalMapping = ri.Cvar_Get("r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
r_parallaxDepthScale = ri.Cvar_Get("r_parallaxDepthScale", "0.03", CVAR_CHEAT);
- r_wrapAroundLighting = ri.Cvar_Get( "r_wrapAroundLighting", "0.7", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_halfLambertLighting = ri.Cvar_Get( "r_halfLambertLighting", "1", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_rimLighting = ri.Cvar_Get("r_rimLighting", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER );
+ r_wrapAroundLighting = ri.Cvar_Get("r_wrapAroundLighting", "0.7", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_halfLambertLighting = ri.Cvar_Get("r_halfLambertLighting", "1", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_rimLighting = ri.Cvar_Get("r_rimLighting", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
r_rimExponent = ri.Cvar_Get("r_rimExponent", "3", CVAR_CHEAT);
AssertCvarRange(r_rimExponent, 0.5, 8.0, qfalse);
@@ -1597,13 +1615,13 @@ void R_Register(void)
r_lockpvs = ri.Cvar_Get("r_lockpvs", "0", CVAR_CHEAT);
r_noportals = ri.Cvar_Get("r_noportals", "0", CVAR_CHEAT);
- r_shadows = ri.Cvar_Get( "cg_shadows", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER );
+ r_shadows = ri.Cvar_Get("cg_shadows", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
AssertCvarRange(r_shadows, 0, SHADOWING_STENCIL, qtrue);
- r_softShadows = ri.Cvar_Get( "r_softShadows", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER );
+ r_softShadows = ri.Cvar_Get("r_softShadows", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
AssertCvarRange(r_softShadows, 0, 6, qtrue);
- r_shadowBlur = ri.Cvar_Get( "r_shadowBlur", "2", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER );
+ r_shadowBlur = ri.Cvar_Get("r_shadowBlur", "2", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SHADER);
r_shadowMapQuality = ri.Cvar_Get("r_shadowMapQuality", "3", CVAR_ARCHIVE | CVAR_LATCH);
AssertCvarRange(r_shadowMapQuality, 0, 4, qtrue);
@@ -1686,12 +1704,12 @@ void R_Register(void)
r_showLightGrid = ri.Cvar_Get("r_showLightGrid", "0", CVAR_CHEAT);
r_showOcclusionQueries = ri.Cvar_Get("r_showOcclusionQueries", "0", CVAR_CHEAT);
r_showBatches = ri.Cvar_Get("r_showBatches", "0", CVAR_CHEAT);
- r_showLightMaps = ri.Cvar_Get( "r_showLightMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
- r_showDeluxeMaps = ri.Cvar_Get( "r_showDeluxeMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
+ r_showLightMaps = ri.Cvar_Get("r_showLightMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
+ r_showDeluxeMaps = ri.Cvar_Get("r_showDeluxeMaps", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
r_showAreaPortals = ri.Cvar_Get("r_showAreaPortals", "0", CVAR_CHEAT);
r_showCubeProbes = ri.Cvar_Get("r_showCubeProbes", "0", CVAR_CHEAT);
r_showBspNodes = ri.Cvar_Get("r_showBspNodes", "0", CVAR_CHEAT);
- r_showParallelShadowSplits = ri.Cvar_Get( "r_showParallelShadowSplits", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER );
+ r_showParallelShadowSplits = ri.Cvar_Get("r_showParallelShadowSplits", "0", CVAR_CHEAT | CVAR_LATCH | CVAR_SHADER);
r_showDecalProjectors = ri.Cvar_Get("r_showDecalProjectors", "0", CVAR_CHEAT);
r_showDeferredDiffuse = ri.Cvar_Get("r_showDeferredDiffuse", "0", CVAR_CHEAT);
View
2  src/engine/rendererGL/tr_light.cpp
@@ -1340,7 +1340,7 @@ static void R_AddEdgeToLightScissor(trRefLight_t * light, vec3_t local1, vec3_t
int i;
vec3_t intersect = {0};
vec3_t world1, world2;
- bool side1, side2;
+ bool side1, side2;
cplane_t *frust;
for(i = 0; i < FRUSTUM_PLANES; i++)
View
240 src/engine/rendererGL/tr_local.h
@@ -160,9 +160,9 @@ enum
typedef struct link_s
{
- void *data;
- int numElements; // only used by sentinels
- struct link_s *prev, *next;
+ void *data;
+ int numElements; // only used by sentinels
+ struct link_s *prev, *next;
} link_t;
static ID_INLINE void InitLink(link_t *l, void *data)
@@ -339,16 +339,16 @@ typedef struct trRefLight_s
qboolean additive; // texture detail is lost tho when the lightmap is dark
vec3_t origin; // l.origin + rotated l.center
vec3_t transformed; // origin in local coordinate system
- vec3_t direction; // for directional lights (sun)
+ vec3_t direction; // for directional lights (sun)
matrix_t transformMatrix; // light to world
matrix_t viewMatrix; // object to light
matrix_t projectionMatrix; // light frustum
- float falloffLength;
+ float falloffLength;
- matrix_t shadowMatrices[MAX_SHADOWMAPS];
- matrix_t shadowMatricesBiased[MAX_SHADOWMAPS];
+ matrix_t shadowMatrices[MAX_SHADOWMAPS];
+ matrix_t shadowMatricesBiased[MAX_SHADOWMAPS];
matrix_t attenuationMatrix; // attenuation * (light view * entity transform)
matrix_t attenuationMatrix2; // attenuation * tcMod matrices
@@ -364,19 +364,19 @@ typedef struct trRefLight_s
float depthFar;
qboolean noDepthBoundsTest;
- bool clipsNearPlane;
+ bool clipsNearPlane;
qboolean noOcclusionQueries;
uint32_t occlusionQueryObject;
uint32_t occlusionQuerySamples;
- link_t multiQuery; // CHC++: list of all nodes that are used by the same occlusion query
+ link_t multiQuery; // CHC++: list of all nodes that are used by the same occlusion query
frustum_t frustum;
- vec4_t localFrustum[6];
+ vec4_t localFrustum[6];
struct VBO_s *frustumVBO;
struct IBO_s *frustumIBO;
uint16_t frustumIndexes;
- uint16_t frustumVerts;
+ uint16_t frustumVerts;
screenRect_t scissor;
@@ -394,9 +394,9 @@ typedef struct trRefLight_s
uint16_t numInteractions; // total interactions
uint16_t numShadowOnlyInteractions;
uint16_t numLightOnlyInteractions;
- bool noSort; // don't sort interactions by material
+ bool noSort; // don't sort interactions by material
- link_t leafs;
+ link_t leafs;
int visCounts[MAX_VISCOUNTS]; // node needs to be traversed if current
//struct bspNode_s **leafs;
@@ -424,10 +424,10 @@ typedef struct
vec3_t worldCorners[8];
// GPU occlusion culling
- qboolean noOcclusionQueries;
+ qboolean noOcclusionQueries;
uint32_t occlusionQueryObject;
uint32_t occlusionQuerySamples;
- link_t multiQuery; // CHC++: list of all nodes that are used by the same occlusion query
+ link_t multiQuery; // CHC++: list of all nodes that are used by the same occlusion query
} trRefEntity_t;
typedef struct
@@ -444,10 +444,10 @@ typedef struct
// useful helper struct
typedef struct vertexHash_s
{
- vec3_t xyz;
- void *data;
+ vec3_t xyz;
+ void *data;
- struct vertexHash_s *next;
+ struct vertexHash_s *next;
} vertexHash_t;
enum
@@ -552,7 +552,7 @@ typedef struct VBO_s
uint32_t vertexesVBO;
uint32_t vertexesSize; // amount of memory data allocated for all vertices in bytes
- uint32_t vertexesNum;
+ uint32_t vertexesNum;
uint32_t ofsXYZ;
uint32_t ofsTexCoords;
uint32_t ofsLightCoords;
@@ -560,15 +560,15 @@ typedef struct VBO_s
uint32_t ofsBinormals;
uint32_t ofsNormals;
uint32_t ofsColors;
- uint32_t ofsPaintColors; // for advanced terrain blending
- uint32_t ofsLightDirections;
+ uint32_t ofsPaintColors; // for advanced terrain blending
+ uint32_t ofsLightDirections;
uint32_t ofsBoneIndexes;
uint32_t ofsBoneWeights;
- uint32_t sizeXYZ;
- uint32_t sizeTangents;
- uint32_t sizeBinormals;
- uint32_t sizeNormals;
+ uint32_t sizeXYZ;
+ uint32_t sizeTangents;
+ uint32_t sizeBinormals;
+ uint32_t sizeNormals;
uint32_t attribs;
} VBO_t;
@@ -579,7 +579,7 @@ typedef struct IBO_s
uint32_t indexesVBO;
uint32_t indexesSize; // amount of memory data allocated for all triangles in bytes
- uint32_t indexesNum;
+ uint32_t indexesNum;
// uint32_t ofsIndexes;
} IBO_t;
@@ -1026,8 +1026,8 @@ typedef struct
expression_t alphaTestExp;
- qboolean tcGen_Environment;
- qboolean tcGen_Lightmap;
+ qboolean tcGen_Environment;
+ qboolean tcGen_Lightmap;
byte constantColor[4]; // for CGEN_CONST and AGEN_CONST
@@ -1056,7 +1056,7 @@ typedef struct
expression_t fresnelScaleExp;
expression_t fresnelBiasExp;
- expression_t normalScaleExp;
+ expression_t normalScaleExp;
expression_t etaExp;
expression_t etaDeltaExp;
@@ -1075,7 +1075,7 @@ typedef struct
qboolean isDetail;
qboolean noFog; // used only for shaders that have fog disabled, so we can enable it for individual stages
- qboolean isFogged;
+ qboolean isFogged;
} shaderStage_t;
struct shaderCommands_s;
@@ -1356,7 +1356,7 @@ enum
ATTR_TANGENT |
ATTR_BINORMAL |
ATTR_NORMAL |
- ATTR_COLOR// |
+ ATTR_COLOR
#if !defined(COMPAT_Q3A) && !defined(COMPAT_ET)
|
@@ -1405,173 +1405,173 @@ typedef struct shaderProgram_s
int32_t u_EnvironmentMap0;
int32_t u_EnvironmentMap1;
- int32_t u_RandomMap;
+ int32_t u_RandomMap;
int32_t u_GrainMap;
int32_t u_VignetteMap;
int32_t u_ColorTextureMatrix;
- matrix_t t_ColorTextureMatrix;
+ matrix_t t_ColorTextureMatrix;
int32_t u_DiffuseTextureMatrix;
- matrix_t t_DiffuseTextureMatrix;
+ matrix_t t_DiffuseTextureMatrix;
int32_t u_NormalTextureMatrix;
- matrix_t t_NormalTextureMatrix;
+ matrix_t t_NormalTextureMatrix;
int32_t u_SpecularTextureMatrix;
- matrix_t t_SpecularTextureMatrix;
+ matrix_t t_SpecularTextureMatrix;
int32_t u_AlphaTest;
- alphaTest_t t_AlphaTest;
+ alphaTest_t t_AlphaTest;
int32_t u_ViewOrigin;
- vec3_t t_ViewOrigin;
+ vec3_t t_ViewOrigin;
- GLint u_DeformParms;
+ GLint u_DeformParms;
int32_t u_Color;
- vec4_t t_Color;
+ vec4_t t_Color;
int32_t u_ColorModulate;
- vec4_t t_ColorModulate;
+ vec4_t t_ColorModulate;
int32_t u_AmbientColor;
- vec3_t t_AmbientColor;
+ vec3_t t_AmbientColor;
int32_t u_LightDir;
- vec3_t t_LightDir;
+ vec3_t t_LightDir;
int32_t u_LightOrigin;
- vec3_t t_LightOrigin;
+ vec3_t t_LightOrigin;
int32_t u_LightColor;
- vec3_t t_LightColor;
+ vec3_t t_LightColor;
int32_t u_LightRadius;
- float t_LightRadius;
+ float t_LightRadius;
int32_t u_LightParallel;
- qboolean t_LightParallel;
+ qboolean t_LightParallel;
int32_t u_LightScale;
- float t_LightScale;
+ float t_LightScale;
int32_t u_LightWrapAround;
- float t_LightWrapAround;
+ float t_LightWrapAround;
int32_t u_LightAttenuationMatrix;
- matrix_t t_LightAttenuationMatrix;
+ matrix_t t_LightAttenuationMatrix;
int32_t u_LightFrustum;
int32_t u_ShadowMatrix;
- matrix_t t_ShadowMatrix;
+ matrix_t t_ShadowMatrix;
int32_t u_ShadowCompare;
- qboolean t_ShadowCompare;
+ qboolean t_ShadowCompare;
int32_t u_ShadowTexelSize;
- float t_ShadowTexelSize;
+ float t_ShadowTexelSize;
int32_t u_ShadowBlur;
- float t_ShadowBlur;
+ float t_ShadowBlur;
- GLint u_ShadowParallelSplitDistances;
- vec4_t t_ShadowParallelSplitDistances;
+ GLint u_ShadowParallelSplitDistances;
+ vec4_t t_ShadowParallelSplitDistances;
int32_t u_RefractionIndex;
- float t_RefractionIndex;
+ float t_RefractionIndex;
int32_t u_FresnelPower;
int32_t u_FresnelScale;
int32_t u_FresnelBias;
- GLint u_NormalScale;
+ GLint u_NormalScale;
int32_t u_EtaRatio;
int32_t u_FogDensity;
int32_t u_FogColor;
- GLint u_FogDistanceVector;
- vec4_t t_FogDistanceVector;
+ GLint u_FogDistanceVector;
+ vec4_t t_FogDistanceVector;
- GLint u_FogDepthVector;
- vec4_t t_FogDepthVector;
+ GLint u_FogDepthVector;
+ vec4_t t_FogDepthVector;
- GLint u_FogEyeT;
- float t_FogEyeT;
+ GLint u_FogEyeT;
+ float t_FogEyeT;
int32_t u_SSAOJitter;
int32_t u_SSAORadius;
- GLint u_ParallaxMapping;
- qboolean t_ParallaxMapping;
+ GLint u_ParallaxMapping;
+ qboolean t_ParallaxMapping;
int32_t u_DepthScale;
- float t_DepthScale;
+ float t_DepthScale;
- GLint u_PortalClipping;
- qboolean t_PortalClipping;
+ GLint u_PortalClipping;
+ qboolean t_PortalClipping;
- GLint u_PortalPlane;
- vec4_t t_PortalPlane;
+ GLint u_PortalPlane;
+ vec4_t t_PortalPlane;
int32_t u_PortalRange;
- float t_PortalRange;
+ float t_PortalRange;
- GLint u_EnvironmentInterpolation;
- float t_EnvironmentInterpolation;
+ GLint u_EnvironmentInterpolation;
+ float t_EnvironmentInterpolation;
- GLint u_HDRKey;
- float t_HDRKey;
+ GLint u_HDRKey;
+ float t_HDRKey;
- GLint u_HDRAverageLuminance;
- float t_HDRAverageLuminance;
+ GLint u_HDRAverageLuminance;
+ float t_HDRAverageLuminance;
- GLint u_HDRMaxLuminance;
- float t_HDRMaxLuminance;
+ GLint u_HDRMaxLuminance;
+ float t_HDRMaxLuminance;
int32_t u_DeformMagnitude;
- float t_DeformMagnitude;
+ float t_DeformMagnitude;
- GLint u_BlurMagnitude;
+ GLint u_BlurMagnitude;
int32_t u_ModelMatrix; // model -> world
- matrix_t t_ModelMatrix;
+ matrix_t t_ModelMatrix;
int32_t u_ViewMatrix; // world -> camera
- matrix_t t_ViewMatrix;
+ matrix_t t_ViewMatrix;
int32_t u_ModelViewMatrix; // model -> camera
- matrix_t t_ModelViewMatrix;
+ matrix_t t_ModelViewMatrix;
int32_t u_ModelViewMatrixTranspose;
- matrix_t t_ModelViewMatrixTranspose;
+ matrix_t t_ModelViewMatrixTranspose;
int32_t u_ProjectionMatrix;
- matrix_t t_ProjectionMatrix;
+ matrix_t t_ProjectionMatrix;
int32_t u_ProjectionMatrixTranspose;
- matrix_t t_ProjectionMatrixTranspose;
+ matrix_t t_ProjectionMatrixTranspose;
int32_t u_ModelViewProjectionMatrix;
- matrix_t t_ModelViewProjectionMatrix;
+ matrix_t t_ModelViewProjectionMatrix;
int32_t u_UnprojectMatrix;
- matrix_t t_UnprojectMatrix;
+ matrix_t t_UnprojectMatrix;
int32_t u_VertexSkinning;
- qboolean t_VertexSkinning;
+ qboolean t_VertexSkinning;
- GLint u_VertexInterpolation;
- float t_VertexInterpolation;
+ GLint u_VertexInterpolation;
+ float t_VertexInterpolation;
int32_t u_BoneMatrix;
int32_t u_Time;
- float t_Time;
+ float t_Time;
} shaderProgram_t;
#define SHADER_PROGRAM_T_OFS(x) ((size_t)&(((shaderProgram_t *)0)->x))
@@ -2369,7 +2369,7 @@ typedef struct
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
- stereoFrame_t stereoFrame;
+ stereoFrame_t stereoFrame;
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc
@@ -2479,7 +2479,7 @@ typedef struct
int originalBrushNumber;
vec3_t bounds[2];
- vec4_t color; // in packed byte format
+ vec4_t color; // in packed byte format
float tcScale; // texture coordinate vector scales
fogParms_t fogParms;
@@ -2500,7 +2500,7 @@ typedef struct
int frameSceneNum; // copied from tr.frameSceneNum
int frameCount; // copied from tr.frameCount
- int viewCount; // copied from tr.viewCount
+ int viewCount; // copied from tr.viewCount
cplane_t portalPlane; // clip anything behind this if mirroring
int viewportX, viewportY, viewportWidth, viewportHeight;
@@ -2510,13 +2510,13 @@ typedef struct
matrix_t projectionMatrix;
matrix_t unprojectionMatrix; // transform pixel window space -> world space
- float parallelSplitDistances[MAX_SHADOWMAPS + 1]; // distances in camera space
+ float parallelSplitDistances[MAX_SHADOWMAPS + 1]; // distances in camera space
frustum_t frustums[MAX_SHADOWMAPS + 1]; // first frustum is the default one with complete zNear - zFar range
// and the other ones are for PSSM
vec3_t visBounds[2];
- float skyFar;
+ float skyFar;
float zNear;
float zFar;
@@ -2525,7 +2525,7 @@ typedef struct
int numInteractions;
struct interaction_s *interactions;
- stereoFrame_t stereoFrame;
+ stereoFrame_t stereoFrame;
} viewParms_t;
@@ -3882,7 +3882,7 @@ typedef struct
frontEndCounters_t pc;
int frontEndMsec; // not in pc due to clearing issue
- vec4_t clipRegion; // 2D clipping region
+ vec4_t clipRegion; // 2D clipping region
//
// put large tables at the end, so most elements will be
@@ -3901,14 +3901,14 @@ typedef struct
FBO_t *fbos[MAX_FBOS];
#if !defined(USE_D3D10)
- GLuint vao;
+ GLuint vao;
#endif
growList_t vbos;
growList_t ibos;
byte *cubeTemp[6]; // 6 textures for cubemap storage
- growList_t cubeProbes; // all cubemaps in a linear growing list
+ growList_t cubeProbes; // all cubemaps in a linear growing list
vertexHash_t **cubeHashTable; // hash table for faster access
// shader indexes from other modules will be looked up in tr.shaders[]
@@ -3967,6 +3967,10 @@ extern cvar_t *r_glMinorVersion;
extern cvar_t *r_glDebugProfile;
extern cvar_t *r_glCoreProfile;
+#ifdef USE_GLSL_OPTIMIZER
+extern cvar_t *r_glslOptimizer;
+#endif
+
extern cvar_t *r_flares; // light flares
extern cvar_t *r_flareSize;
extern cvar_t *r_flareFade;
@@ -4565,16 +4569,16 @@ typedef struct shaderCommands_s
qboolean skipTangentSpaces;
qboolean shadowVolume;
- qboolean skipVBO;
+ qboolean skipVBO;
int16_t lightmapNum;
- int16_t fogNum;
+ int16_t fogNum;
uint32_t numIndexes;
uint32_t numVertexes;
- int multiDrawPrimitives;
- glIndex_t* multiDrawIndexes[MAX_MULTIDRAW_PRIMITIVES];
- int multiDrawCounts[MAX_MULTIDRAW_PRIMITIVES];
+ int multiDrawPrimitives;
+ glIndex_t* multiDrawIndexes[MAX_MULTIDRAW_PRIMITIVES];
+ int multiDrawCounts[MAX_MULTIDRAW_PRIMITIVES];
qboolean vboVertexSkinning;
matrix_t boneMatrices[MAX_BONES];
@@ -4604,7 +4608,7 @@ void Tess_Begin( void (*stageIteratorFunc)(),
int fogNum);
// *INDENT-ON*
void Tess_End(void);
-void Tess_EndBegin();
+void Tess_EndBegin();
void Tess_DrawElements();
void Tess_CheckOverflow(int verts, int indexes);
@@ -4632,8 +4636,8 @@ Add a polyhedron that is composed of four triangular faces
*/
void Tess_AddTetrahedron(vec4_t tetraVerts[4], vec4_t const color);
-void Tess_AddCube(const vec3_t position, const vec3_t minSize, const vec3_t maxSize, const vec4_t color);
-void Tess_AddCubeWithNormals(const vec3_t position, const vec3_t minSize, const vec3_t maxSize, const vec4_t color);
+void Tess_AddCube(const vec3_t position, const vec3_t minSize, const vec3_t maxSize, const vec4_t color);
+void Tess_AddCubeWithNormals(const vec3_t position, const vec3_t minSize, const vec3_t maxSize, const vec4_t color);
void Tess_InstantQuad(vec4_t quadVerts[4]);
void Tess_UpdateVBOs(uint32_t attribBits);
@@ -5181,17 +5185,17 @@ void RE_BeginFrame(stereoFrame_t stereoFrame);
void RE_EndFrame(int *frontEndMsec, int *backEndMsec);
-void LoadTGA(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
+void LoadTGA(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
void LoadJPG(const char *filename, unsigned char **pic, int *width, int *height, byte alphaByte);
void SaveJPG(char *filename, int quality, int image_width, int image_height, unsigned char *image_buffer);
int SaveJPGToBuffer(byte * buffer, size_t bufferSize, int quality, int image_width, int image_height, byte * image_buffer);
-void LoadPNG(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
+void LoadPNG(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
void SavePNG(const char *name, const byte * pic, int width, int height, int numBytes, qboolean flip);
#ifdef USE_WEBP
-void LoadWEBP(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
+void LoadWEBP(const char *name, byte ** pic, int *width, int *height, byte alphaByte);
#endif
// video stuff
@@ -5210,11 +5214,11 @@ void R_DoneFreeType();
void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t * font);
// bani
-void RE_RenderToTexture(int textureid, int x, int y, int w, int h);
-void RE_Finish(void);
+void RE_RenderToTexture(int textureid, int x, int y, int w, int h);
+void RE_Finish(void);
-void LoadRGBEToFloats(const char *name, float **pic, int *width, int *height, qboolean doGamma, qboolean toneMap, qboolean compensate);
-void LoadRGBEToHalfs(const char *name, unsigned short ** halfImage, int *width, int *height);
+void LoadRGBEToFloats(const char *name, float **pic, int *width, int *height, qboolean doGamma, qboolean toneMap, qboolean compensate);
+void LoadRGBEToHalfs(const char *name, unsigned short ** halfImage, int *width, int *height);
#if defined(__cplusplus)
}
View
6 src/engine/rendererGL/tr_mesh.cpp
@@ -263,8 +263,8 @@ void R_AddMDVSurfaces(trRefEntity_t * ent)
mdvSurface_t *mdvSurface = 0;
shader_t *shader = 0;
int lod;
- bool personalModel;
- int fogNum;
+ bool personalModel;
+ int fogNum;
// don't add third_person objects if not in a portal
personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal;
@@ -367,7 +367,7 @@ void R_AddMDVInteractions(trRefEntity_t * ent, trRefLight_t * light)
mdvSurface_t *mdvSurface = 0;
shader_t *shader = 0;
int lod;
- bool personalModel;
+ bool personalModel;
byte cubeSideBits;
interactionType_t iaType = IA_DEFAULT;
View
4 src/engine/rendererGL/tr_model.cpp
@@ -94,8 +94,8 @@ asked for again.
qhandle_t RE_RegisterModel(const char *name)
{
model_t *mod;
- byte *buffer;
- int bufferLen;
+ byte *buffer;
+ int bufferLen = 0;
int lod;
int ident;
qboolean loaded;
View
6 src/engine/rendererGL/tr_model_md3.cpp
@@ -291,9 +291,9 @@ qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, const c
GLuint ofsNormals;
GLuint sizeXYZ;
- GLuint sizeTangents;
- GLuint sizeBinormals;
- GLuint sizeNormals;
+ GLuint sizeTangents = 0;
+ GLuint sizeBinormals = 0;
+ GLuint sizeNormals = 0;
int vertexesNum;
int f;
View
57 src/engine/rendererGL/tr_model_psk.cpp
@@ -204,6 +204,7 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk indent ('%s' should be '%s')\n", modName, chunkHeader.ident, "VTXW0000");
FreeMemStream(stream);
+ Com_Dealloc(points);
return qfalse;
}
@@ -211,6 +212,7 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk dataSize ('%i' should be '%i')\n", modName, chunkHeader.dataSize, sizeof(axVertex_t));
FreeMemStream(stream);
+ Com_Dealloc(points);
return qfalse;
}
@@ -225,6 +227,8 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has vertex with point index out of range (%i while max %i)\n", modName, vertex->pointIndex, numPoints);
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
return qfalse;
}
@@ -259,6 +263,8 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk indent ('%s' should be '%s')\n", modName, chunkHeader.ident, "FACE0000");
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
return qfalse;
}
@@ -266,6 +272,8 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk dataSize ('%i' should be '%i')\n", modName, chunkHeader.dataSize, sizeof(axTriangle_t));
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
return qfalse;
}
@@ -283,6 +291,9 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has triangle with vertex index out of range (%i while max %i)\n", modName, triangle->indexes[j], numVertexes);
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
return qfalse;
}
}
@@ -298,6 +309,9 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk indent ('%s' should be '%s')\n", modName, chunkHeader.ident, "MATT0000");
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
return qfalse;
}
@@ -305,6 +319,9 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk dataSize ('%i' should be '%i')\n", modName, chunkHeader.dataSize, sizeof(axMaterial_t));
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
return qfalse;
}
@@ -332,6 +349,10 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has vertex with material index out of range (%i while max %i)\n", modName, vertex->materialIndex, numMaterials);
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
return qfalse;
}
}
@@ -342,6 +363,10 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has triangle with material index out of range (%i while max %i)\n", modName, triangle->materialIndex, numMaterials);
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
return qfalse;
}
}
@@ -352,6 +377,10 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk indent ('%s' should be '%s')\n", modName, chunkHeader.ident, "REFSKELT");
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
return qfalse;
}
@@ -359,6 +388,10 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk dataSize ('%i' should be '%i')\n", modName, chunkHeader.dataSize, sizeof(axReferenceBone_t));
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
return qfalse;
}
@@ -410,6 +443,11 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk indent ('%s' should be '%s')\n", modName, chunkHeader.ident, "RAWWEIGHTS");
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
+ Com_Dealloc(refBones);
return qfalse;
}
@@ -417,6 +455,11 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has wrong chunk dataSize ('%i' should be '%i')\n", modName, chunkHeader.dataSize, sizeof(axBoneWeight_t));
FreeMemStream(stream);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
+ Com_Dealloc(refBones);
return qfalse;
}
@@ -463,11 +506,23 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
if(md5->numBones < 1)
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has no bones\n", modName);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
+ Com_Dealloc(refBones);
+ Com_Dealloc(axWeights);
return qfalse;
}
if(md5->numBones > MAX_BONES)
{
ri.Printf(PRINT_WARNING, "R_LoadPSK: '%s' has more than %i bones (%i)\n", modName, MAX_BONES, md5->numBones);
+ Com_Dealloc(points);
+ Com_Dealloc(vertexes);
+ Com_Dealloc(triangles);
+ Com_Dealloc(materials);
+ Com_Dealloc(refBones);
+ Com_Dealloc(axWeights);
return qfalse;
}
//ri.Printf(PRINT_ALL, "R_LoadPSK: '%s' has %i bones\n", modName, md5->numBones);
@@ -936,6 +991,8 @@ qboolean R_LoadPSK(model_t * mod, byte *buffer, int bufferSize, const char *modN
Com_Dealloc(vertexes);
Com_Dealloc(triangles);
Com_Dealloc(materials);
+ Com_Dealloc(refBones);
+ Com_Dealloc(axWeights);
ri.Printf(PRINT_ALL, "%i VBO surfaces created for PSK model '%s'\n", md5->numVBOSurfaces, modName);
View
34 src/engine/rendererGL/tr_public.h
@@ -63,19 +63,19 @@ typedef struct
// size display elements. Returns false if the renderer couldn't
// be initialized.
qboolean (*BeginRegistration) (glconfig_t * config, glconfig2_t * glconfig2);
- qhandle_t (*RegisterModel) (const char *name);
- //qhandle_t (*RegisterModelAllLODs) (const char *name);
- qhandle_t (*RegisterSkin) (const char *name);
+ qhandle_t (*RegisterModel) (const char *name);
+ //qhandle_t (*RegisterModelAllLODs) (const char *name);
+ qhandle_t (*RegisterSkin) (const char *name);
qhandle_t (*RegisterShader) (const char *name);
- qhandle_t (*RegisterShaderNoMip) (const char *name);
+ qhandle_t (*RegisterShaderNoMip) (const char *name);
#if defined(USE_REFLIGHT)
- qhandle_t (*RegisterShaderLightAttenuation) (const char *name);
+ qhandle_t (*RegisterShaderLightAttenuation) (const char *name);
#endif
void (*RegisterFont) (const char *fontName, int pointSize, fontInfo_t * font);
void (*LoadWorld) (const char *name);
- qboolean (*GetSkinModel) (qhandle_t skinid, const char *type, char *name); //----(SA) added
- qhandle_t (*GetShaderFromModel) (qhandle_t modelid, int surfnum, int withlightmap); //----(SA) added
+ qboolean (*GetSkinModel) (qhandle_t skinid, const char *type, char *name); //----(SA) added
+ qhandle_t (*GetShaderFromModel) (qhandle_t modelid, int surfnum, int withlightmap); //----(SA) added
// the vis data is a large enough block of data that we go to the trouble
// of sharing it with the clipmodel subsystem
@@ -99,7 +99,7 @@ typedef struct
qhandle_t hShader, int flags);
// Dushan
- void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
+ void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
//----(SA)
void (*AddCoronaToScene) (const vec3_t org, float r, float g, float b, float scale, int id, qboolean visible);
@@ -111,7 +111,7 @@ typedef struct
void (*RestoreViewParms) ();
void (*SetColor) (const float *rgba); // NULL = 1,1,1,1
- void (*SetClipRegion)(const float *region);
+ void (*SetClipRegion)(const float *region);
void (*DrawStretchPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader); // 0 = white
void (*DrawRotatedPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle); // NERVE - SMF
void (*DrawStretchPicGradient) (float x, float y, float w, float h, float s1, float t1, float s2, float t2,
@@ -144,17 +144,17 @@ typedef struct
void (*DrawDebugPolygon) (int color, int numpoints, float *points);
void (*DrawDebugText) (const vec3_t org, float r, float g, float b, const char *text, qboolean neverOcclude);
- qboolean (*GetEntityToken) (char *buffer, int size);
+ qboolean (*GetEntityToken) (char *buffer, int size);
void (*AddPolyBufferToScene) (polyBuffer_t * pPolyBuffer);
void (*SetGlobalFog) (qboolean restore, int duration, float r, float g, float b, float depthForOpaque);
- qboolean (*inPVS) (const vec3_t p1, const vec3_t p2);
+ qboolean (*inPVS) (const vec3_t p1, const vec3_t p2);
void (*purgeCache) (void);
- qboolean (*LoadDynamicShader) (const char *shadername, const char *shadertext);
+ qboolean (*LoadDynamicShader) (const char *shadername, const char *shadertext);
void (*RenderToTexture) (int textureid, int x, int y, int w, int h);
@@ -171,8 +171,8 @@ typedef struct
// RB: alternative skeletal animation system
#if defined(USE_REFENTITY_ANIMATIONSYSTEM)
- qhandle_t (*RegisterAnimation) (const char *name);
- int (*CheckSkeleton) (refSkeleton_t * skel, qhandle_t model, qhandle_t anim);
+ qhandle_t (*RegisterAnimation) (const char *name);
+ int (*CheckSkeleton) (refSkeleton_t * skel, qhandle_t model, qhandle_t anim);
int (*BuildSkeleton) (refSkeleton_t * skel, qhandle_t anim, int startFrame, int endFrame, float frac,
qboolean clearOrigin);
int (*BlendSkeleton) (refSkeleton_t * skel, const refSkeleton_t * blend, float frac);
@@ -182,7 +182,7 @@ typedef struct
#endif
// XreaL END
- fontInfo_t* (*GetFontFromFontSet)( qhandle_t fontSet, float fontScale );
+ fontInfo_t* (*GetFontFromFontSet)( qhandle_t fontSet, float fontScale );
} refexport_t;
//
@@ -256,9 +256,9 @@ typedef struct
e_status(*CIN_RunCinematic) (int handle);
// Dushan
- long (*ftol)(float f);
+ long (*ftol)(float f);
const char *(*Con_GetText)( int console );
- void (*HTTP_PostBug)(const char *fileName);
+ void (*HTTP_PostBug)(const char *fileName);
// XreaL BEGIN
void *(*Sys_GetSystemHandles) (void);
View
3  src/engine/rendererGL/tr_scene.cpp
@@ -99,7 +99,8 @@ void R_ToggleSmpFrame(void)
RE_ClearScene
====================
*/
-void RE_ClearScene(void) {
+void RE_ClearScene(void)
+{
r_firstSceneLight = r_numLights;
r_firstSceneEntity = r_numEntities;
r_firstScenePoly = r_numPolys;
View
4 src/engine/rendererGL/tr_shade_calc.cpp
@@ -226,7 +226,7 @@ float RB_EvalExpression(const expression_t * exp, float defaultValue)
float value;
float value1;
float value2;
- opstring_t opStrings;
+ extern const opstring_t opStrings[];
numOps = 0;
value = 0;
@@ -365,7 +365,7 @@ float RB_EvalExpression(const expression_t * exp, float defaultValue)
if(numOps < 2)
{
ri.Printf(PRINT_ALL, "WARNING: shader %s has numOps < 2 for binary operator %s\n", tess.surfaceShader->name,
- opStrings.s);
+ opStrings[op.type].s);
return defaultValue;
}
View
5 src/engine/rendererGL/tr_shader.cpp
@@ -181,7 +181,7 @@ static qboolean ParseVector(char **text, int count, float *v)
}
-opstring_t opStrings[] = {
+extern const opstring_t opStrings[] = {
{"bad", OP_BAD}
,
@@ -286,7 +286,7 @@ opstring_t opStrings[] = {
static void GetOpType(char *token, expOperation_t * op)
{
- opstring_t *opString;
+ const opstring_t *opString;
char tableName[MAX_QPATH];
int hash;
shaderTable_t *tb;
@@ -1813,7 +1813,6 @@ static qboolean ParseStage(shaderStage_t * stage, char **text)
num = stage->bundle[0].numImages;
if(num < MAX_IMAGE_ANIMATIONS)
{
- //stage->bundle[0].image[num] = R_FindImageFile(token, IF_NONE, FT_DEFAULT, WT_REPEAT, shader.name);
stage->bundle[0].image[num] = R_FindImageFile(token, imageBits, filterType, WT_REPEAT, shader.name);
if(!stage->bundle[0].image[num])
{
View
4 src/engine/rendererGL/tr_surface.cpp
@@ -909,8 +909,8 @@ static void Tess_SurfacePolychain(srfPoly_t * p)
void Tess_SurfacePolybuffer(srfPolyBuffer_t * surf)
{
int i;
- int numIndexes;
- int numVertexes;
+ int numIndexes;
+ int numVertexes;
glIndex_t *indices;
float *xyzw;
float *st;
View
324 src/engine/rendererGL/tr_vbo.cpp
</
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
R_CreateVBO
============
*/
-VBO_t *R_CreateVBO( const char *name, byte *vertexes, int vertexesSize, vboUsage_t usage )
+VBO_t *R_CreateVBO(const char *name, byte *vertexes, int vertexesSize, vboUsage_t usage)
{
#if defined(USE_D3D10)
// TODO
@@ -36,7 +36,7 @@ VBO_t *R_CreateVBO( const char *name, byte *vertexes, int vertexesSize,
VBO_t *vbo;
int glUsage;
- switch ( usage )
+ switch (usage)
{
case VBO_USAGE_STATIC:
glUsage = GL_STATIC_DRAW;
@@ -48,7 +48,7 @@ VBO_t *R_CreateVBO( const char *name, byte *vertexes, int vertexesSize,
default:
glUsage = 0; //Prevents warning
- Com_Error( ERR_FATAL, "bad vboUsage_t given: %i", usage );
+ Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage);
}
if ( strlen( name ) >= MAX_QPATH )
@@ -59,10 +59,10 @@ VBO_t *R_CreateVBO( const char *name, byte *vertexes, int vertexesSize,
// make sure the render thread is stopped
R_SyncRenderThread();
- vbo = (VBO_t*)ri.Hunk_Alloc( sizeof( *vbo ), h_low );
- Com_AddToGrowList( &tr.vbos, vbo );
+ vbo = (VBO_t*)ri.Hunk_Alloc(sizeof(*vbo), h_low);
+ Com_AddToGrowList(&tr.vbos, vbo);
- Q_strncpyz( vbo->name, name, sizeof( vbo->name ) );
+ Q_strncpyz(vbo->name, name, sizeof(vbo->name));
vbo->ofsXYZ = 0;
vbo->ofsTexCoords = 0;
@@ -101,22 +101,22 @@ VBO_t *R_CreateVBO( const char *name, byte *vertexes, int vertexesSize,
R_CreateVBO2
============
*/
-VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *verts, unsigned int stateBits, vboUsage_t usage )
+VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t *verts, unsigned int stateBits, vboUsage_t usage)
{
#if defined(USE_D3D10)
// TODO
return NULL;
#else
- VBO_t *vbo;
- int i, j;
+ VBO_t *vbo;
+ int i, j;
- byte *data;
- int dataSize;
- int dataOfs;
+ byte *data;
+ int dataSize;
+ int dataOfs;
- int glUsage;
+ int glUsage;
- switch ( usage )
+ switch (usage)
{
case VBO_USAGE_STATIC:
glUsage = GL_STATIC_DRAW;
@@ -128,26 +128,26 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
default:
glUsage = 0;
- Com_Error( ERR_FATAL, "bad vboUsage_t given: %i", usage );
+ Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage);
}
- if ( !numVertexes )
+ if(!numVertexes)
{
return NULL;
}
- if ( strlen( name ) >= MAX_QPATH )
+ if(strlen(name) >= MAX_QPATH)
{
- ri.Error( ERR_DROP, "R_CreateVBO2: \"%s\" is too long\n", name );
+ ri.Error(ERR_DROP, "R_CreateVBO2: \"%s\" is too long\n", name);
}
// make sure the render thread is stopped
R_SyncRenderThread();
- vbo = (VBO_t*)ri.Hunk_Alloc( sizeof( *vbo ), h_low );
- Com_AddToGrowList( &tr.vbos, vbo );
+ vbo = (VBO_t*)ri.Hunk_Alloc(sizeof(*vbo), h_low);
+ Com_AddToGrowList(&tr.vbos, vbo);
- Q_strncpyz( vbo->name, name, sizeof( vbo->name ) );
+ Q_strncpyz(vbo->name, name, sizeof(vbo->name));
vbo->ofsXYZ = 0;
vbo->ofsTexCoords = 0;
@@ -167,8 +167,8 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
vbo->sizeNormals = 0;
// create VBO
- dataSize = numVertexes * ( sizeof( vec4_t ) * 9 );
- data = (byte*)ri.Hunk_AllocateTempMemory( dataSize );
+ dataSize = numVertexes * (sizeof(vec4_t) * 9);
+ data = (byte*)ri.Hunk_AllocateTempMemory(dataSize);
dataOfs = 0;
// since this is all float, point tmp directly into data
@@ -191,42 +191,42 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
VERTEXCOPY( xyz );
// feed vertex texcoords
- if ( stateBits & ATTR_TEXCOORD )
+ if(stateBits & ATTR_TEXCOORD)
{
vbo->ofsTexCoords = dataOfs;
VERTEXCOPY( st );
}
// feed vertex lightmap texcoords
- if ( stateBits & ATTR_LIGHTCOORD )
+ if(stateBits & ATTR_LIGHTCOORD)
{
vbo->ofsLightCoords = dataOfs;
VERTEXCOPY( lightmap );
}
// feed vertex tangents
- if ( stateBits & ATTR_TANGENT )
+ if(stateBits & ATTR_TANGENT)
{
vbo->ofsTangents = dataOfs;
VERTEXCOPY( tangent );
}
// feed vertex binormals
- if ( stateBits & ATTR_BINORMAL )
+ if(stateBits & ATTR_BINORMAL)
{
vbo->ofsBinormals = dataOfs;
VERTEXCOPY( binormal );
}
// feed vertex normals
- if ( stateBits & ATTR_NORMAL )
+ if(stateBits & ATTR_NORMAL)
{
vbo->ofsNormals = dataOfs;
VERTEXCOPY( normal );
}
// feed vertex colors
- if ( stateBits & ATTR_COLOR )
+ if(stateBits & ATTR_COLOR)
{
vbo->ofsColors = dataOfs;
VERTEXCOPY( lightColor );
@@ -235,14 +235,14 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
#if !defined( COMPAT_Q3A ) && !defined( COMPAT_ET )
// feed vertex paint colors
- if ( stateBits & ATTR_PAINTCOLOR )
+ if(stateBits & ATTR_PAINTCOLOR)
{
vbo->ofsPaintColors = dataOfs;
VERTEXCOPY( paintColor );
}
// feed vertex light directions
- if ( stateBits & ATTR_LIGHTDIRECTION )
+ if(stateBits & ATTR_LIGHTDIRECTION)
{
vbo->ofsLightDirections = dataOfs;
VERTEXCOPY( lightDirection );
@@ -262,7 +262,7 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
GL_CheckErrors();
- ri.Hunk_FreeTempMemory( data );
+ ri.Hunk_FreeTempMemory(data);
return vbo;
#endif
@@ -273,16 +273,16 @@ VBO_t *R_CreateVBO2( const char *name, int numVertexes, srfVert_t *vert
R_CreateIBO
============
*/
-IBO_t *R_CreateIBO( const char *name, byte *indexes, int indexesSize, vboUsage_t usage )
+IBO_t *R_CreateIBO(const char *name, byte *indexes, int indexesSize, vboUsage_t usage)
{
#if defined(USE_D3D10)
// TODO
return NULL;
#else
- IBO_t *ibo;
- int glUsage;
+ IBO_t *ibo;
+ int glUsage;
- switch ( usage )
+ switch (usage)
{
case VBO_USAGE_STATIC:
glUsage = GL_STATIC_DRAW;
@@ -294,21 +294,21 @@ IBO_t *R_CreateIBO( const char *name, byte *indexes, int indexesSize, v
default:
glUsage = 0;
- Com_Error( ERR_FATAL, "bad vboUsage_t given: %i", usage );
+ Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage);
}
- if ( strlen( name ) >= MAX_QPATH )
+ if(strlen(name) >= MAX_QPATH)
{
- ri.Error( ERR_DROP, "R_CreateIBO: \"%s\" is too long\n", name );
+ ri.Error(ERR_DROP, "R_CreateIBO: \"%s\" is too long\n", name);
}
// make sure the render thread is stopped
R_SyncRenderThread();
- ibo = (IBO_t*)ri.Hunk_Alloc( sizeof( *ibo ), h_low );
- Com_AddToGrowList( &tr.ibos, ibo );
+ ibo = (IBO_t*)ri.Hunk_Alloc(sizeof(*ibo), h_low);
+ Com_AddToGrowList(&tr.ibos, ibo);
- Q_strncpyz( ibo->name, name, sizeof( ibo->name ) );
+ Q_strncpyz(ibo->name, name, sizeof(ibo->name));
ibo->indexesSize = indexesSize;
@@ -330,24 +330,24 @@ IBO_t *R_CreateIBO( const char *name, byte *indexes, int indexesSize, v
R_CreateIBO2
============
*/
-IBO_t *R_CreateIBO2( const char *name, int numTriangles, srfTriangle_t *triangles, vboUsage_t usage )
+IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t *triangles, vboUsage_t usage)
{
#if defined(USE_D3D10)
// TODO
return NULL;
#else
- IBO_t *ibo;
- int i, j;
+ IBO_t *ibo;
+ int i, j;
- byte *indexes;
- int indexesSize;
- int indexesOfs;
+ byte *indexes;
+ int indexesSize;
+ int indexesOfs;
- srfTriangle_t *tri;
- glIndex_t index;
- int glUsage;
+ srfTriangle_t *tri;
+ glIndex_t index;
+ int glUsage;
- switch ( usage )
+ switch (usage)
{
case VBO_USAGE_STATIC:
glUsage = GL_STATIC_DRAW;
@@ -359,40 +359,40 @@ IBO_t *R_CreateIBO2( const char *name, int numTriangles, srfTriangle_t
default:
glUsage = 0;
- Com_Error( ERR_FATAL, "bad vboUsage_t given: %i", usage );
+ Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage);
}
- if ( !numTriangles )
+ if(!numTriangles)
{
return NULL;
}
- if ( strlen( name ) >= MAX_QPATH )
+ if(strlen(name) >= MAX_QPATH)
{
- ri.Error( ERR_DROP, "R_CreateIBO2: \"%s\" is too long\n", name );
+ ri.Error(ERR_DROP, "R_CreateIBO2: \"%s\" is too long\n", name);
}
// make sure the render thread is stopped
R_SyncRenderThread();
- ibo = (IBO_t*)ri.Hunk_Alloc( sizeof( *ibo ), h_low );
- Com_AddToGrowList( &tr.ibos, ibo );
+ ibo = (IBO_t*)ri.Hunk_Alloc(sizeof(*ibo), h_low);
+ Com_AddToGrowList(&tr.ibos, ibo);
- Q_strncpyz( ibo->name, name, sizeof( ibo->name ) );
+ Q_strncpyz(ibo->name, name, sizeof(ibo->name));
- indexesSize = numTriangles * 3 * sizeof( glIndex_t );
- indexes = (byte*)ri.Hunk_AllocateTempMemory( indexesSize );
+ indexesSize = numTriangles * 3 * sizeof(glIndex_t);
+ indexes = (byte*)ri.Hunk_AllocateTempMemory(indexesSize);
indexesOfs = 0;
//ri.Printf(PRINT_ALL, "sizeof(glIndex_t) = %i\n", sizeof(glIndex_t));
- for ( i = 0, tri = triangles; i < numTriangles; i++, tri++ )
+ for(i = 0, tri = triangles; i < numTriangles; i++, tri++)
{
- for ( j = 0; j < 3; j++ )
+ for(j = 0; j < 3; j++)
{
- index = tri->indexes[ j ];
- memcpy( indexes + indexesOfs, &index, sizeof( glIndex_t ) );
- indexesOfs += sizeof( glIndex_t );
+ index = tri->indexes[j];
+ memcpy(indexes + indexesOfs, &index, sizeof(glIndex_t));
+ indexesOfs += sizeof(glIndex_t);
}
}
@@ -408,7 +408,7 @@ IBO_t *R_CreateIBO2( const char *name, int numTriangles, srfTriangle_t
GL_CheckErrors();
- ri.Hunk_FreeTempMemory( indexes );
+ ri.Hunk_FreeTempMemory(indexes);
return ibo;
#endif
@@ -419,25 +419,25 @@ IBO_t *R_CreateIBO2( const char *name, int numTriangles, srfTriangle_t
R_BindVBO
============
*/
-void R_BindVBO( VBO_t *vbo )
+void R_BindVBO(VBO_t *vbo)
{
- if ( !vbo )
+ if(!vbo)
{
//R_BindNullVBO();
- ri.Error( ERR_DROP, "R_BindNullVBO: NULL vbo" );
+ ri.Error(ERR_DROP, "R_BindNullVBO: NULL vbo");
return;
}
- if ( r_logFile->integer )
+ if(r_logFile->integer)
{
// don't just call LogComment, or we will get a call to va() every frame!
- GLimp_LogComment( va( "--- R_BindVBO( %s ) ---\n", vbo->name ) );
+ GLimp_LogComment(va("--- R_BindVBO( %s ) ---\n", vbo->name));
}
#if defined(USE_D3D10)
// TODO
#else
- if ( glState.currentVBO != vbo )
+ if(glState.currentVBO != vbo)
{
glState.currentVBO = vbo;
glState.vertexAttribPointersSet = 0;
@@ -460,14 +460,14 @@ void R_BindVBO( VBO_t *vbo )
R_BindNullVBO
============
*/
-void R_BindNullVBO( void )
+void R_BindNullVBO(void)
{
GLimp_LogComment( "--- R_BindNullVBO ---\n" );
#if defined(USE_D3D10)
// TODO
#else
- if ( glState.currentVBO )
+ if(glState.currentVBO)
{
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glState.currentVBO = NULL;
@@ -482,25 +482,25 @@ void R_BindNullVBO( void )
R_BindIBO
============
*/
-void R_BindIBO( IBO_t *ibo )
+void R_BindIBO(IBO_t * ibo)
{
- if ( !ibo )
+ if(!ibo)
{
//R_BindNullIBO();
- ri.Error( ERR_DROP, "R_BindIBO: NULL ibo" );
+ ri.Error(ERR_DROP, "R_BindIBO: NULL ibo");
return;
}
- if ( r_logFile->integer )
+ if(r_logFile->integer)
{
// don't just call LogComment, or we will get a call to va() every frame!
- GLimp_LogComment( va( "--- R_BindIBO( %s ) ---\n", ibo->name ) );
+ GLimp_LogComment(va("--- R_BindIBO( %s ) ---\n", ibo->name));
}
#if defined(USE_D3D10)
// TODO
#else
- if ( glState.currentIBO != ibo )
+ if(glState.currentIBO != ibo)
{
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO );
@@ -534,45 +534,45 @@ void R_BindNullIBO( void )
static void R_InitUnitCubeVBO()
{
- vec3_t mins = { -1, -1, -1 };
- vec3_t maxs = { 1, 1, 1 };
+ vec3_t mins = {-1, -1, -1};
+ vec3_t maxs = { 1, 1, 1};
- int i;
+ int i;
// vec4_t quadVerts[4];
- srfVert_t *verts;
- srfTriangle_t *triangles;
+ srfVert_t *verts;
+ srfTriangle_t *triangles;
- if ( glConfig.smpActive )
+ if(glConfig.smpActive)
{
- ri.Error( ERR_FATAL, "R_InitUnitCubeVBO: FIXME SMP" );
+ ri.Error(ERR_FATAL, "R_InitUnitCubeVBO: FIXME SMP");
}
tess.multiDrawPrimitives = 0;
tess.numIndexes = 0;
tess.numVertexes = 0;
- Tess_AddCube( vec3_origin, mins, maxs, colorWhite );
+ Tess_AddCube(vec3_origin, mins, maxs, colorWhite);
- verts = (srfVert_t*)ri.Hunk_AllocateTempMemory( tess.numVertexes * sizeof( srfVert_t ) );
- triangles = (srfTriangle_t*)ri.Hunk_AllocateTempMemory( ( tess.numIndexes / 3 ) * sizeof( srfTriangle_t ) );
+ verts = (srfVert_t*)ri.Hunk_AllocateTempMemory(tess.numVertexes * sizeof(srfVert_t));
+ triangles = (srfTriangle_t*)ri.Hunk_AllocateTempMemory((tess.numIndexes / 3) * sizeof(srfTriangle_t));
- for ( i = 0; i < tess.numVertexes; i++ )
+ for(i = 0; i < tess.numVertexes; i++)
{
- VectorCopy( tess.xyz[ i ], verts[ i ].xyz );
+ VectorCopy(tess.xyz[i], verts[i].xyz);
}
- for ( i = 0; i < ( tess.numIndexes / 3 ); i++ )
+ for(i = 0; i < (tess.numIndexes / 3); i++)
{
- triangles[ i ].indexes[ 0 ] = tess.indexes[ i * 3 + 0 ];
- triangles[ i ].indexes[ 1 ] = tess.indexes[ i * 3 + 1 ];
- triangles[ i ].indexes[ 2 ] = tess.indexes[ i * 3 + 2 ];
+ triangles[i].indexes[0] = tess.indexes[i * 3 + 0];
+ triangles[i].indexes[1] = tess.indexes[i * 3 + 1];
+ triangles[i].indexes[2] = tess.indexes[i * 3 + 2];
}
- tr.unitCubeVBO = R_CreateVBO2( "unitCube_VBO", tess.numVertexes, verts, ATTR_POSITION, VBO_USAGE_STATIC );
- tr.unitCubeIBO = R_CreateIBO2( "unitCube_IBO", tess.numIndexes / 3, triangles, VBO_USAGE_STATIC );
+ tr.unitCubeVBO = R_CreateVBO2("unitCube_VBO", tess.numVertexes, verts, ATTR_POSITION, VBO_USAGE_STATIC);
+ tr.unitCubeIBO = R_CreateIBO2("unitCube_IBO", tess.numIndexes / 3, triangles, VBO_USAGE_STATIC);
- ri.Hunk_FreeTempMemory( triangles );
- ri.Hunk_FreeTempMemory( verts );
+ ri.Hunk_FreeTempMemory(triangles);
+ ri.Hunk_FreeTempMemory(verts);
tess.multiDrawPrimitives = 0;
tess.numIndexes = 0;
@@ -584,39 +584,39 @@ static void R_InitUnitCubeVBO()
R_InitVBOs
============
*/
-void R_InitVBOs( void )
+void R_InitVBOs(void)
{
int dataSize;
byte *data;
- ri.Printf( PRINT_ALL, "------- R_InitVBOs -------\n" );
+ ri.Printf(PRINT_ALL, "------- R_InitVBOs -------\n");
- Com_InitGrowList( &tr.vbos, 100 );
- Com_InitGrowList( &tr.ibos, 100 );
+ Com_InitGrowList(&tr.vbos, 100);
+ Com_InitGrowList(&tr.ibos, 100);
- dataSize = sizeof( vec4_t ) * SHADER_MAX_VERTEXES * 11;
+ dataSize = sizeof(vec4_t) * SHADER_MAX_VERTEXES * 11;
data = (byte*)Com_Allocate(dataSize);
memset(data, 0, dataSize);
- tess.vbo = R_CreateVBO( "tessVertexArray_VBO", data, dataSize, VBO_USAGE_DYNAMIC );
+ tess.vbo = R_CreateVBO("tessVertexArray_VBO", data, dataSize, VBO_USAGE_DYNAMIC);
#if !defined(USE_D3D10)
tess.vbo->ofsXYZ = 0;
- tess.vbo->ofsTexCoords = tess.vbo->ofsXYZ + sizeof( tess.xyz );
- tess.vbo->ofsLightCoords = tess.vbo->ofsTexCoords + sizeof( tess.texCoords );
- tess.vbo->ofsTangents = tess.vbo->ofsLightCoords + sizeof( tess.lightCoords );
- tess.vbo->ofsBinormals = tess.vbo->ofsTangents + sizeof( tess.tangents );
- tess.vbo->ofsNormals = tess.vbo->ofsBinormals + sizeof( tess.binormals );
- tess.vbo->ofsColors = tess.vbo->ofsNormals + sizeof( tess.normals );
-
-#if !defined( COMPAT_Q3A ) && !defined( COMPAT_ET )
- tess.vbo->ofsPaintColors = tess.vbo->ofsColors + sizeof( tess.colors );
- tess.vbo->ofsLightDirections = tess.vbo->ofsPaintColors + sizeof( tess.paintColors );
+ tess.vbo->ofsTexCoords = tess.vbo->ofsXYZ + sizeof(tess.xyz);
+ tess.vbo->ofsLightCoords = tess.vbo->ofsTexCoords + sizeof(tess.texCoords);
+ tess.vbo->ofsTangents = tess.vbo->ofsLightCoords + sizeof(tess.lightCoords);
+ tess.vbo->ofsBinormals = tess.vbo->ofsTangents + sizeof(tess.tangents);
+ tess.vbo->ofsNormals = tess.vbo->ofsBinormals + sizeof(tess.binormals);
+ tess.vbo->ofsColors = tess.vbo->ofsNormals + sizeof(tess.normals);
+
+#if !defined(COMPAT_Q3A) && !defined(COMPAT_ET)
+ tess.vbo->ofsPaintColors = tess.vbo->ofsColors + sizeof(tess.colors);
+ tess.vbo->ofsLightDirections = tess.vbo->ofsPaintColors + sizeof(tess.paintColors);
#endif
- tess.vbo->sizeXYZ = sizeof( tess.xyz );
- tess.vbo->sizeTangents = sizeof( tess.tangents );
- tess.vbo->sizeBinormals = sizeof( tess.binormals );
- tess.vbo->sizeNormals = sizeof( tess.normals );
+ tess.vbo->sizeXYZ = sizeof(tess.xyz);
+ tess.vbo->sizeTangents = sizeof(tess.tangents);
+ tess.vbo->sizeBinormals = sizeof(tess.binormals);
+ tess.vbo->sizeNormals = sizeof(tess.normals);
#endif
Com_Dealloc(data);
@@ -646,39 +646,39 @@ void R_InitVBOs( void )
R_ShutdownVBOs
============
*/
-void R_ShutdownVBOs( void )
+void R_ShutdownVBOs(void)
{
- int i;
- VBO_t *vbo;
- IBO_t *ibo;
+ int i;
+ VBO_t *vbo;
+ IBO_t *ibo;
- ri.Printf( PRINT_ALL, "------- R_ShutdownVBOs -------\n" );
+ ri.Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n");
R_BindNullVBO();
R_BindNullIBO();
- for ( i = 0; i < tr.vbos.currentElements; i++ )
+ for(i = 0; i < tr.vbos.currentElements; i++)
{
- vbo = ( VBO_t * ) Com_GrowListElement( &tr.vbos, i );
+ vbo = (VBO_t *) Com_GrowListElement(&tr.vbos, i);
#if defined(USE_D3D10)
// TODO
#else
- if ( vbo->vertexesVBO )
+ if(vbo->vertexesVBO)
{
glDeleteBuffers( 1, &vbo->vertexesVBO );
}
#endif
}
- for ( i = 0; i < tr.ibos.currentElements; i++ )
+ for(i = 0; i < tr.ibos.currentElements; i++)
{
- ibo = ( IBO_t * ) Com_GrowListElement( &tr.ibos, i );
+ ibo = (IBO_t *) Com_GrowListElement(&tr.ibos, i);
#if defined(USE_D3D10)
// TODO
#else
- if ( ibo->indexesVBO )
+ if(ibo->indexesVBO)
{
glDeleteBuffers( 1, &ibo->indexesVBO );
}
@@ -717,8 +717,8 @@ void R_ShutdownVBOs( void )
#endif // #if defined(USE_BSP_CLUSTERSURFACE_MERGING)
- Com_DestroyGrowList( &tr.vbos );
- Com_DestroyGrowList( &tr.ibos );
+ Com_DestroyGrowList(&tr.vbos);
+ Com_DestroyGrowList(&tr.ibos);
}
/*
@@ -726,45 +726,45 @@ void R_ShutdownVBOs( void )
R_VBOList_f