Skip to content

Commit 735598b

Browse files
committed
- Model fog fix
- Suppressing redundant sound warnings to developer print - Preliminary DDS texture loading - Dropping renderergl1 and renderergl2 as they're unsupported, redundant, stale code with none of the new improvements, and we don't use modularized renderers. Still having these files in the tree implies we use them and that can bring confusion.
1 parent 3827ec0 commit 735598b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+915
-64631
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ ifeq ($(WINFOUR),1)
258258
BASE_CFLAGS += -DUSE_INTERNAL_JPEG
259259
SDL_VERSION=1
260260
USE_CURL=0
261-
CLIENTBIN=oa95
261+
# CLIENTBIN=oa95
262262
endif
263263

264264
#############################################################################
@@ -1175,7 +1175,7 @@ endif
11751175
ifeq ($(NO_STRIP),1)
11761176
STRIP_FLAG =
11771177
else
1178-
STRIP_FLAG = -s
1178+
STRIP_FLAG = -s
11791179
endif
11801180

11811181
BASE_CFLAGS += -DPRODUCT_VERSION=\\\"$(VERSION)\\\"
@@ -1288,7 +1288,7 @@ endef
12881288
#############################################################################
12891289

12901290
default: release
1291-
all: debug release
1291+
all: debug release
12921292

12931293
debug:
12941294
@$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(BASE_CFLAGS) $(DEPEND_CFLAGS)" \
@@ -1778,6 +1778,7 @@ Q3ROAOBJ = \
17781778
$(B)/renderer_oa/tr_image_jpg.o \
17791779
$(B)/renderer_oa/tr_image_bmp.o \
17801780
$(B)/renderer_oa/tr_image_tga.o \
1781+
$(B)/renderer_oa/tr_image_dds.o \
17811782
$(B)/renderer_oa/tr_image_pcx.o \
17821783
$(B)/renderer_oa/tr_init.o \
17831784
$(B)/renderer_oa/tr_light.o \
@@ -1852,6 +1853,7 @@ Q3RSOFTOBJ = \
18521853
$(B)/renderer_oa/tr_image_jpg.o \
18531854
$(B)/renderer_oa/tr_image_bmp.o \
18541855
$(B)/renderer_oa/tr_image_tga.o \
1856+
$(B)/renderer_oa/tr_image_dds.o \
18551857
$(B)/renderer_oa/tr_image_pcx.o \
18561858
$(B)/renderer_oa/tr_init.o \
18571859
$(B)/renderer_oa/tr_light.o \

code/client/snd_dma.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,17 @@ static sfx_t *S_FindName( const char *name ) {
267267
}
268268

269269
if (!name[0]) {
270-
Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" );
270+
Com_DPrintf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" );
271271
return NULL;
272272
}
273273

274274
if (strlen(name) >= MAX_QPATH) {
275-
Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", name );
275+
Com_DPrintf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", name );
276276
return NULL;
277277
}
278278

279279
if (name[0] == '*') {
280-
Com_Printf( S_COLOR_YELLOW "WARNING: Tried to load player sound directly: %s\n", name );
280+
Com_DPrintf( S_COLOR_YELLOW "WARNING: Tried to load player sound directly: %s\n", name );
281281
return NULL;
282282
}
283283

@@ -371,7 +371,7 @@ sfxHandle_t S_Base_RegisterSound( const char *name, qboolean compressed ) {
371371

372372
if ( sfx->soundData ) {
373373
if ( sfx->defaultSound ) {
374-
Com_Printf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName );
374+
Com_DPrintf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName );
375375
return 0;
376376
}
377377
return sfx - s_knownSfx;
@@ -383,7 +383,7 @@ sfxHandle_t S_Base_RegisterSound( const char *name, qboolean compressed ) {
383383
S_memoryLoad(sfx);
384384

385385
if ( sfx->defaultSound ) {
386-
Com_Printf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName );
386+
Com_DPrintf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName );
387387
return 0;
388388
}
389389

@@ -1428,7 +1428,7 @@ static void S_OpenBackgroundStream( const char *filename ) {
14281428
// Open stream
14291429
s_backgroundStream = S_CodecOpenStream(filename);
14301430
if(!s_backgroundStream) {
1431-
Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", filename );
1431+
Com_DPrintf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", filename );
14321432
return;
14331433
}
14341434

code/renderer_oa/tr_extensions.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ GLvoid (APIENTRYP qglGetVertexAttribPointervARB) (GLuint index, GLenum pname, GL
112112
GLvoid (APIENTRYP qglColorTableEXT)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
113113
GLvoid (APIENTRYP qglColorTableSGI)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
114114

115+
// leilei - DDS/DXT
116+
117+
GLvoid (APIENTRYP qglCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
118+
GLvoid (APIENTRYP qglColorTableEXT)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
119+
GLvoid (APIENTRYP qglColorTableSGI)( GLint, GLint, GLint, GLint, GLint, const GLvoid *);
120+
115121
/*
116122
typedef enum {
117123
GLHW_GENERIC, // where everthing works the way it should
@@ -272,6 +278,26 @@ void GLimp_InitExtraExtensions()
272278
{
273279
ri.Printf( PRINT_ALL, "...GL_EXT_paletted_texture not found\n" );
274280
}
281+
// leilei - DDS/DXT
282+
textureCompressionSupport = qfalse;
283+
if ( GLimp_HaveExtension( "GL_ARB_texture_compression" ) )
284+
{
285+
if ( r_loadDDS->integer ) {
286+
qglCompressedTexImage2DARB = (GLvoid (APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)) SDL_GL_GetProcAddress("glCompressedTexImage2DARB");
287+
{
288+
ri.Printf( PRINT_ALL, "...using GL_ARB_texture_compression\n");
289+
textureCompressionSupport = qtrue;
290+
}
291+
}
292+
else
293+
{
294+
ri.Printf( PRINT_ALL, "...ignoring GL_ARB_texture_compression\n" );
295+
}
296+
}
297+
else
298+
{
299+
ri.Printf( PRINT_ALL, "...GL_ARB_texture_compression not found\n" );
300+
}
275301

276302
#ifdef _WIN32
277303
// leilei - 3dfx gamma

code/renderer_oa/tr_image.c

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ void R_ImageList_f( void ) {
531531
sizeSuffix = "Gb";
532532
}
533533

534-
//ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName);
535-
ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s %f %f\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName, image->loadTime, image->procTime);
534+
ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName);
535+
//ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s %f %f\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName, image->loadTime, image->procTime);
536536

537537
estTotalSize += estSize;
538538
estTotalTimeLoaded += image->loadTime + image->procTime;
@@ -2131,6 +2131,10 @@ Finds or loads the given image.
21312131
Returns NULL if it fails, not a default image.
21322132
==============
21332133
*/
2134+
#ifdef BROKEN_DDS
2135+
// DDS/DXT
2136+
image_t *R_LoadDDSImage(const char *name, int bits, filterType_t filterType, wrapType_t wrapType);
2137+
#endif
21342138
image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
21352139
{
21362140
image_t *image;
@@ -2140,7 +2144,9 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
21402144
long hash;
21412145
float oldtime;
21422146
float loadtime;
2143-
2147+
#ifdef BROKEN_DDS
2148+
char ddsName[1024];
2149+
#endif
21442150
if (!name) {
21452151
return NULL;
21462152
}
@@ -2162,6 +2168,31 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
21622168
return image;
21632169
}
21642170
}
2171+
#ifdef BROKEN_DDS
2172+
// leilei - DDS - do it here, so we can have a hardware compressed texture instead. The normal means of texture loading expects pixels to be returned which we won't do.
2173+
if(textureCompressionSupport && r_loadDDS->integer)
2174+
{
2175+
int bits; // no bits
2176+
int whatclamp;
2177+
Q_strncpyz(ddsName, name, sizeof(ddsName));
2178+
COM_StripExtension(ddsName, ddsName, sizeof(ddsName));
2179+
Q_strcat(ddsName, sizeof(ddsName), ".dds");
2180+
2181+
// if (glWrapClampMode == GL_CLAMP_TO_EDGE)
2182+
// whatclamp = WT_CLAMP;
2183+
// else
2184+
// whatclamp = WT_REPEAT;
2185+
// try to load a customized .dds texture
2186+
2187+
image = R_LoadDDSImage(ddsName, bits, 0, whatclamp);
2188+
if(image != NULL)
2189+
{
2190+
// ri.Printf(PRINT_ALL, "found custom .dds '%s'\n", ddsName);
2191+
return image;
2192+
}
2193+
}
2194+
2195+
#endif
21652196

21662197
// leilei - Detail texture hack
21672198
// to kill artifacts of shimmer of pattern of terrible
@@ -2953,3 +2984,44 @@ void R_SkinList_f( void ) {
29532984
ri.Printf (PRINT_ALL, "------------------\n");
29542985
}
29552986

2987+
#ifdef BROKEN_DDS
2988+
// leilei - for DDS loading, which relies on this function...
2989+
/*
2990+
================
2991+
R_AllocImage
2992+
================
2993+
*/
2994+
image_t *R_AllocImage(const char *name, qboolean linkIntoHashTable)
2995+
{
2996+
image_t *image;
2997+
long hash;
2998+
char buffer[1024];
2999+
3000+
// if(strlen(name) >= MAX_QPATH)
3001+
if(strlen(name) >= 1024)
3002+
{
3003+
ri.Error(ERR_DROP, "R_AllocImage: \"%s\" image name is too long\n", name);
3004+
return NULL;
3005+
}
3006+
3007+
image = ri.Hunk_Alloc(sizeof(image_t), h_low);
3008+
Com_Memset(image, 0, sizeof(image_t));
3009+
3010+
3011+
qglGenTextures(1, &image->texnum);
3012+
3013+
//Com_AddToGrowList(&tr.images, image);
3014+
3015+
Q_strncpyz(image->imgName, name, sizeof(image->imgName));
3016+
3017+
if(linkIntoHashTable)
3018+
{
3019+
Q_strncpyz(buffer, name, sizeof(buffer));
3020+
hash = generateHashValue(buffer);
3021+
image->next = hashTable[hash];
3022+
hashTable[hash] = image;
3023+
}
3024+
3025+
return image;
3026+
}
3027+
#endif

code/renderer_oa/tr_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int maxAnisotropy = 0;
2929
float displayAspect = 0.0f;
3030
qboolean vertexShaders = qfalse;
3131
qboolean postprocess = qfalse;
32+
qboolean textureCompressionSupport = qfalse; // leilei - compressed textures
3233
qboolean palettedTextureSupport = qfalse; // leilei - paletted textures
3334

3435
char depthimage;
@@ -105,6 +106,7 @@ cvar_t *r_ext_texture_env_add;
105106
cvar_t *r_ext_texture_filter_anisotropic;
106107
cvar_t *r_ext_max_anisotropy;
107108
cvar_t *r_ext_vertex_shader;
109+
cvar_t *r_loadDDS; // leilei - loading DDS textures
108110
cvar_t *r_ext_paletted_texture; // leilei - Paletted Texture
109111
cvar_t *r_ext_gamma_control; // leilei - 3dfx gamma control
110112
cvar_t *r_postprocess;
@@ -1134,6 +1136,7 @@ void R_Register( void )
11341136
r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic",
11351137
"0", CVAR_ARCHIVE | CVAR_LATCH );
11361138
r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH );
1139+
r_loadDDS = ri.Cvar_Get( "r_loadDDS", "1", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - compressed texture support
11371140
r_ext_paletted_texture = ri.Cvar_Get( "r_ext_paletted_texture", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - paletted texture support
11381141
r_ext_gamma_control = ri.Cvar_Get( "r_ext_gamma_control", "1", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - 3dfx gamma support
11391142

code/renderer_oa/tr_local.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*
23
===========================================================================
34
Copyright (C) 1999-2005 Id Software, Inc.
@@ -49,6 +50,7 @@ typedef unsigned int glIndex_t;
4950
#define SHADERNUM_BITS 14
5051
#define MAX_SHADERS (1<<SHADERNUM_BITS)
5152

53+
extern qboolean textureCompressionSupport; // leilei - compressed texture
5254
extern qboolean palettedTextureSupport; // leilei - paletted texture
5355

5456
typedef struct dlight_s {
@@ -1442,6 +1444,7 @@ extern cvar_t *r_lensReflection1;
14421444
extern cvar_t *r_lensReflection2;
14431445
extern cvar_t *r_lensReflectionBrightness;
14441446

1447+
extern cvar_t *r_loadDDS; // leilei - Compressed Texture
14451448
extern cvar_t *r_ext_paletted_texture; // leilei - Paletted Texture
14461449
extern cvar_t *r_ext_gamma_control; // leilei - 3dfx gamma control
14471450
extern cvar_t *r_specMode;
@@ -2171,7 +2174,7 @@ void R_LoadJPG( const char *name, byte **pic, int *width, int *height );
21712174
void R_LoadPCX( const char *name, byte **pic, int *width, int *height );
21722175
void R_LoadPNG( const char *name, byte **pic, int *width, int *height );
21732176
void R_LoadTGA( const char *name, byte **pic, int *width, int *height );
2174-
2177+
//void R_LoadDDS( const char *name, byte **pic, int *width, int *height );
21752178
/*
21762179
=============================================================
21772180
=============================================================

code/renderer_oa/tr_shader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
29882988
ri.Printf( PRINT_WARNING, "WARNING: missing parameters for rgbMod in shader '%s'\n", shader.name );
29892989
continue;
29902990
}
2991-
if ( !Q_stricmp( token, "glow" ) )
2991+
else if ( !Q_stricmp( token, "glow" ) )
29922992
{
29932993
// TODO: Parse "entity" and "vertex" for their colors, for railguns and maps
29942994
token = COM_ParseExt( text, qfalse );
@@ -3008,7 +3008,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
30083008

30093009
stage->rgbMod = CMOD_GLOW;
30103010
}
3011-
if ( !Q_stricmp( token, "uvcol" ) )
3011+
else if ( !Q_stricmp( token, "uvcol" ) )
30123012
{
30133013
// Parse color
30143014
token = COM_ParseExt( text, qfalse );
@@ -3028,22 +3028,22 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
30283028

30293029
stage->rgbMod = CMOD_UVCOL;
30303030
}
3031-
if ( !Q_stricmp( token, "normtoalpha" ) )
3031+
else if ( !Q_stricmp( token, "normtoalpha" ) )
30323032
{
30333033
// normalize colors, but average color prior is alpha.
30343034
stage->rgbMod = CMOD_NORMALIZETOALPHA;
30353035
}
3036-
if ( !Q_stricmp( token, "normtoalphafast" ) )
3036+
else if ( !Q_stricmp( token, "normtoalphafast" ) )
30373037
{
30383038
// normalize and use the first vert's color on whole surface, but average color prior is alpha.
30393039
stage->rgbMod = CMOD_NORMALIZETOALPHAFAST;
30403040
}
3041-
if ( !Q_stricmp( token, "lighting" ) )
3041+
else if ( !Q_stricmp( token, "lighting" ) )
30423042
{
30433043
// modulate a standard diffuse light on top of existing vertex colors
30443044
stage->rgbMod = CMOD_LIGHTING;
30453045
}
3046-
if ( !Q_stricmp( token, "opaque" ) )
3046+
else if ( !Q_stricmp( token, "opaque" ) )
30473047
{
30483048
// modulate a standard diffuse light on top of existing vertex colors
30493049
stage->rgbMod = CMOD_OPAQUE;

code/renderercommon/tr_common.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ typedef enum
4747
IMGFLAG_GENNORMALMAP = 0x0100,
4848
} imgFlags_t;
4949

50+
// DDS stuff
51+
52+
53+
typedef enum
54+
{
55+
FT_DEFAULT,
56+
FT_LINEAR,
57+
FT_NEAREST
58+
} filterType_t;
59+
60+
typedef enum
61+
{
62+
WT_REPEAT,
63+
WT_CLAMP, // don't repeat the texture for texture coords outside [0, 1]
64+
WT_EDGE_CLAMP,
65+
WT_ZERO_CLAMP, // guarantee 0,0,0,255 edge for projected textures
66+
WT_ALPHA_ZERO_CLAMP // guarante 0 alpha edge for projected textures
67+
} wrapType_t;
68+
69+
5070
typedef struct image_s {
5171
char imgName[MAX_QPATH]; // game path, including extension
5272
int width, height; // source image
@@ -67,6 +87,11 @@ typedef struct image_s {
6787

6888
float loadTime; // leilei - time taken loading image
6989
float procTime; // leilei - time taken processing image/uploading to vram
90+
91+
// DXT/DDS stuff
92+
GLenum ddsType;
93+
filterType_t filterType;
94+
wrapType_t wrapType;
7095
} image_t;
7196

7297
// any change in the LIGHTMAP_* defines here MUST be reflected in

0 commit comments

Comments
 (0)