Several renderer fixes for 3dfx hardware:
- Try to determine which 3dfx card we are using - Use GL_CLAMP for 3dfx instead, fixes dynamic lights/skyboxes/etc. (GL_CLAMP_TO_EDGE becomes GL_REPEAT on older 3dfx drivers) - Support for 3dfx gamma control and overbrights restored - Indexed w/ alpha color is now forced GL_RGBA on Voodoo Graphics (v1) - attempt at silencing the 3dfx splash
This commit is contained in:
@@ -10,6 +10,11 @@
|
||||
|
||||
#include "tr_local.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID ); // leilei - 3dfx gamma fix
|
||||
BOOL ( WINAPI * qwglSetDeviceGammaRamp3DFX)( HDC, LPVOID );
|
||||
#endif
|
||||
|
||||
// GL_ARB_shader_objects
|
||||
GLvoid (APIENTRYP qglDeleteObjectARB) (GLhandleARB obj);
|
||||
GLhandleARB (APIENTRYP qglGetHandleARB) (GLenum pname);
|
||||
@@ -120,6 +125,7 @@ typedef enum {
|
||||
*/
|
||||
|
||||
int softwaremode; // leilei - detect for software mode
|
||||
int voodootype; // leilei - detect for voodoo revision
|
||||
|
||||
/** From renderer_opengl2 (v28) */
|
||||
static qboolean GLimp_HaveExtension(const char *ext)
|
||||
@@ -265,6 +271,41 @@ void GLimp_InitExtraExtensions()
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "...GL_EXT_paletted_texture not found\n" );
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// leilei - 3dfx gamma
|
||||
// WGL_3DFX_gamma_control
|
||||
qwglGetDeviceGammaRamp3DFX = NULL;
|
||||
qwglSetDeviceGammaRamp3DFX = NULL;
|
||||
|
||||
if ( strstr( glConfig.extensions_string, "WGL_3DFX_gamma_control" ) )
|
||||
{
|
||||
if ( !r_ignorehwgamma->integer && r_ext_gamma_control->integer )
|
||||
{
|
||||
qwglGetDeviceGammaRamp3DFX = ( BOOL ( WINAPI * )( HDC, LPVOID ) ) SDL_GL_GetProcAddress( "wglGetDeviceGammaRamp3DFX" );
|
||||
qwglSetDeviceGammaRamp3DFX = ( BOOL ( WINAPI * )( HDC, LPVOID ) ) SDL_GL_GetProcAddress( "wglSetDeviceGammaRamp3DFX" );
|
||||
|
||||
if ( qwglGetDeviceGammaRamp3DFX && qwglSetDeviceGammaRamp3DFX )
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "...using WGL_3DFX_gamma_control\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
qwglGetDeviceGammaRamp3DFX = NULL;
|
||||
qwglSetDeviceGammaRamp3DFX = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "...ignoring WGL_3DFX_gamma_control\n" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "...WGL_3DFX_gamma_control not found\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
// XXX This is likely too late to check the com_abnormalExit cvar
|
||||
if( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) )
|
||||
{
|
||||
@@ -302,6 +343,40 @@ void GLimp_InitExtraExtensions()
|
||||
// VOODOO GRAPHICS w/ 2MB
|
||||
else if ( strstr( buf, "voodoo graphics/1 tmu/2 mb" ) )
|
||||
{
|
||||
voodootype = 1;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo Graphics assumed\n" );
|
||||
}
|
||||
// any Voodoo Graphics
|
||||
else if ( strstr( buf, "voodoo graphics" ) )
|
||||
{
|
||||
voodootype = 1;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo Graphics assumed\n" );
|
||||
}
|
||||
else if ( strstr( buf, "voodoo2" ) )
|
||||
{
|
||||
voodootype = 2;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo2 assumed\n" );
|
||||
}
|
||||
else if ( strstr( buf, "voodoo3" ) )
|
||||
{
|
||||
voodootype = 3;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo3 assumed\n" );
|
||||
}
|
||||
else if ( strstr( buf, "voodoo4" ) )
|
||||
{
|
||||
voodootype = 4;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo4 assumed\n" );
|
||||
}
|
||||
else if ( strstr( buf, "voodoo5" ) )
|
||||
{
|
||||
voodootype = 4;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo5 assumed\n" );
|
||||
}
|
||||
// Just any voodoo at this point.
|
||||
else if ( strstr( buf, "voodoo" ) )
|
||||
{
|
||||
voodootype = 1;
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo of some sort assumed (V1 mode)\n" );
|
||||
}
|
||||
else if ( strstr( buf, "glzicd" ) )
|
||||
{
|
||||
|
@@ -138,11 +138,11 @@ void R_PickTexturePalette(int alpha)
|
||||
{
|
||||
qglEnable(GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
|
||||
if (alpha)
|
||||
if (alpha)
|
||||
qglColorTableEXT( GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, paltable );
|
||||
else
|
||||
else
|
||||
qglColorTableEXT( GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, paltablergb );
|
||||
|
||||
|
||||
qglEnable(GL_SHARED_TEXTURE_PALETTE_EXT);
|
||||
}
|
||||
|
||||
@@ -234,6 +234,11 @@ void R_InitPalette( void ) {
|
||||
else
|
||||
paletteability = 0;
|
||||
|
||||
// change the transparent color to black
|
||||
palettemain[255*3] = 0;
|
||||
palettemain[255*3+1] = 0;
|
||||
palettemain[255*3+2] = 0;
|
||||
|
||||
|
||||
if (paletteability) // load this palette for GL
|
||||
{
|
||||
@@ -2008,11 +2013,14 @@ static void Upload8( unsigned *data,
|
||||
a *= 1.9;
|
||||
a /= 255;
|
||||
a *= 255;
|
||||
if (a > 1 && voodootype ==1 ) isalphaedrgba = 1; // voodoo graphics fix
|
||||
}
|
||||
|
||||
|
||||
if (paletteability)
|
||||
R_PickTexturePalette(1);
|
||||
|
||||
|
||||
if (paletteability && !isalphaedrgba) // Preparing for native upload
|
||||
{
|
||||
|
||||
@@ -2032,6 +2040,7 @@ static void Upload8( unsigned *data,
|
||||
thecol = 255; // transparent color
|
||||
}
|
||||
scan[i] = thecol;
|
||||
samples = 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2072,7 +2081,13 @@ static void Upload8( unsigned *data,
|
||||
{
|
||||
|
||||
// select proper internal format
|
||||
if ( samples == 3 )
|
||||
|
||||
|
||||
if ( samples == 1 )
|
||||
{
|
||||
internalFormat = GL_LUMINANCE; // leilei - gl has no knowledge of a paletted format, so use this for imagelist
|
||||
}
|
||||
else if ( samples == 3 )
|
||||
{
|
||||
internalFormat = GL_RGB;
|
||||
}
|
||||
@@ -2080,6 +2095,7 @@ static void Upload8( unsigned *data,
|
||||
{
|
||||
internalFormat = GL_RGBA;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// copy or resample data as appropriate for first MIP level
|
||||
@@ -2241,10 +2257,19 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
|
||||
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
if (flags & IMGFLAG_CLAMPTOEDGE)
|
||||
glWrapClampMode = GL_CLAMP_TO_EDGE;
|
||||
if (voodootype){ // leilei - 3dfx needs the old behavior
|
||||
if (flags & IMGFLAG_CLAMPTOEDGE)
|
||||
glWrapClampMode = GL_CLAMP;
|
||||
else
|
||||
glWrapClampMode = GL_REPEAT;
|
||||
}
|
||||
else
|
||||
glWrapClampMode = GL_REPEAT;
|
||||
{
|
||||
if (flags & IMGFLAG_CLAMPTOEDGE)
|
||||
glWrapClampMode = GL_CLAMP_TO_EDGE;
|
||||
else
|
||||
glWrapClampMode = GL_REPEAT;
|
||||
}
|
||||
|
||||
// lightmaps are always allocated on TMU 1
|
||||
if ( qglActiveTextureARB && isLightmap ) {
|
||||
|
@@ -30,12 +30,15 @@ float displayAspect = 0.0f;
|
||||
qboolean vertexShaders = qfalse;
|
||||
qboolean postprocess = qfalse;
|
||||
qboolean palettedTextureSupport = qfalse; // leilei - paletted textures
|
||||
|
||||
char depthimage;
|
||||
|
||||
glstate_t glState;
|
||||
|
||||
static void GfxInfo_f( void );
|
||||
|
||||
extern int voodootype;
|
||||
|
||||
#ifdef USE_RENDERER_DLOPEN
|
||||
cvar_t *com_altivec;
|
||||
#endif
|
||||
@@ -104,6 +107,7 @@ cvar_t *r_ext_texture_filter_anisotropic;
|
||||
cvar_t *r_ext_max_anisotropy;
|
||||
cvar_t *r_ext_vertex_shader;
|
||||
cvar_t *r_ext_paletted_texture; // leilei - Paletted Texture
|
||||
cvar_t *r_ext_gamma_control; // leilei - 3dfx gamma control
|
||||
cvar_t *r_postprocess;
|
||||
|
||||
cvar_t *r_ignoreGLErrors;
|
||||
@@ -1110,6 +1114,18 @@ void GfxInfo_f( void )
|
||||
if ( r_finish->integer ) {
|
||||
ri.Printf( PRINT_ALL, "Forcing glFinish\n" );
|
||||
}
|
||||
if (voodootype){
|
||||
|
||||
if (voodootype == 1)
|
||||
ri.Printf( PRINT_ALL, "3Dfx Voodoo Graphics assumed\n" );
|
||||
else if (voodootype == 2)
|
||||
ri.Printf( PRINT_ALL, "3Dfx Voodoo2 assumed\n" );
|
||||
else if (voodootype == 3)
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo3 assumed\n" );
|
||||
else if (voodootype == 4)
|
||||
ri.Printf( PRINT_ALL, "3dfx Voodoo 4 or 5 assumed\n" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1136,6 +1152,7 @@ void R_Register( void )
|
||||
"0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_ext_paletted_texture = ri.Cvar_Get( "r_ext_paletted_texture", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - paletted texture support
|
||||
r_ext_gamma_control = ri.Cvar_Get( "r_ext_gamma_control", "1", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - 3dfx gamma support
|
||||
|
||||
r_postprocess = ri.Cvar_Get( "r_postprocess", "none", CVAR_ARCHIVE|CVAR_LATCH );
|
||||
r_ext_vertex_shader = ri.Cvar_Get( "r_ext_vertex_shader", "0", CVAR_ARCHIVE|CVAR_LATCH );
|
||||
|
@@ -1360,6 +1360,7 @@ extern cvar_t *r_lensReflection2;
|
||||
extern cvar_t *r_lensReflectionBrightness;
|
||||
|
||||
extern cvar_t *r_ext_paletted_texture; // leilei - Paletted Texture
|
||||
extern cvar_t *r_ext_gamma_control; // leilei - 3dfx gamma control
|
||||
extern cvar_t *r_specMode;
|
||||
//extern cvar_t *r_waveMode;
|
||||
|
||||
@@ -2330,6 +2331,7 @@ void R_AltBrightnessInit( void );
|
||||
void R_FilmScreen( void ); // leilei - film effect
|
||||
extern int softwaremode;
|
||||
extern int leifxmode;
|
||||
extern int voodootype; // 0 - none 1 - Voodoo Graphics 2 - Voodoo2, 3 - Voodoo Banshee/3, 4 - Voodoo4/5
|
||||
|
||||
void RB_UpdateMotionBlur (void);
|
||||
void R_MotionBlur_BackupScreen(int which);
|
||||
|
@@ -740,6 +740,11 @@ extern void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs);
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
|
||||
// leilei - 3dfx gamma fix
|
||||
extern BOOL ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID );
|
||||
extern BOOL ( WINAPI * qwglSetDeviceGammaRamp3DFX)( HDC, LPVOID );
|
||||
|
||||
#endif
|
||||
|
||||
extern HGLRC(APIENTRY * qwglCreateContextAttribsARB) (HDC hdC, HGLRC hShareContext, const int *attribList);
|
||||
|
@@ -29,6 +29,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "../renderercommon/tr_common.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// leilei - 3dfx gamma fix
|
||||
BOOL ( WINAPI * qwglGetDeviceGammaRamp3DFX)( HDC, LPVOID );
|
||||
BOOL ( WINAPI * qwglSetDeviceGammaRamp3DFX)( HDC, LPVOID );
|
||||
#endif
|
||||
/*
|
||||
=================
|
||||
GLimp_SetGamma
|
||||
@@ -86,6 +91,19 @@ void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned
|
||||
}
|
||||
}
|
||||
|
||||
// leilei - 3dfx gamma support
|
||||
#ifdef _WIN32
|
||||
if ( qwglSetDeviceGammaRamp3DFX )
|
||||
{
|
||||
HDC hDC;// = GetDC( hWnd );
|
||||
hDC = GetDC( GetForegroundWindow() );
|
||||
qwglSetDeviceGammaRamp3DFX( hDC, table );
|
||||
ReleaseDC( GetForegroundWindow(), hDC );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
SDL_SetGammaRamp(table[0], table[1], table[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -845,6 +845,15 @@ success:
|
||||
// http://bugzilla.icculus.org/show_bug.cgi?id=4316
|
||||
glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
// leilei - 3dfx gamma
|
||||
if ( qwglSetDeviceGammaRamp3DFX )
|
||||
{
|
||||
glConfig.deviceSupportsGamma = 1; // force it
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( -1 == r_ignorehwgamma->integer)
|
||||
glConfig.deviceSupportsGamma = 1;
|
||||
|
||||
|
@@ -773,6 +773,9 @@ void Sys_PlatformInit( void )
|
||||
else
|
||||
SDL_VIDEODRIVER_externallySet = qfalse;
|
||||
|
||||
// leilei - no 3dfx splashes please
|
||||
_putenv("FX_GLIDE_NO_SPLASH=1");
|
||||
|
||||
if(timeGetDevCaps(&ptc, sizeof(ptc)) == MMSYSERR_NOERROR)
|
||||
{
|
||||
timerResolution = ptc.wPeriodMin;
|
||||
|
Reference in New Issue
Block a user