FindArg cleanup - GL-Debug and SDL arguments
This commit is contained in:
parent
3354c26219
commit
2434d100a8
|
@ -1,5 +1,9 @@
|
|||
D2X-Rebirth Changelog
|
||||
|
||||
20070723
|
||||
--------
|
||||
arch/ogl/gr.c, arch/include/internal.h, arch/ogl/ogl.c, arch/sdl/gr.c, include/args.h, include/ogl_init.h, main/inferno.c, main/args.c: FindArg cleanup - GL-Debug and SDL arguments
|
||||
|
||||
20070722
|
||||
--------
|
||||
include/args.h, include/error.h, main/newmenu.c, main/network.c, main/inferno.c, main/menu.c, main/gamerend.c, main/automap.c, main/game.c, main/game.h, main/gamecntl.c, misc/args.c: Code cleanup and small fixes
|
||||
|
|
|
@ -127,10 +127,6 @@ const char *gl_vendor, *gl_renderer, *gl_version, *gl_extensions;
|
|||
|
||||
void ogl_get_verinfo(void)
|
||||
{
|
||||
long t;
|
||||
|
||||
float anisotropic_max = 0;
|
||||
|
||||
gl_vendor = (const char *) glGetString (GL_VENDOR);
|
||||
gl_renderer = (const char *) glGetString (GL_RENDERER);
|
||||
gl_version = (const char *) glGetString (GL_VERSION);
|
||||
|
@ -138,12 +134,6 @@ void ogl_get_verinfo(void)
|
|||
|
||||
con_printf(CON_VERBOSE, "OpenGL: vendor: %s\nOpenGL: renderer: %s\nOpenGL: version: %s\n",gl_vendor,gl_renderer,gl_version);
|
||||
|
||||
ogl_intensity4_ok = 1;
|
||||
ogl_luminance4_alpha4_ok = 1;
|
||||
ogl_rgba2_ok = 1;
|
||||
ogl_gettexlevelparam_ok = 1;
|
||||
ogl_setgammaramp_ok = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
dglMultiTexCoord2fARB = (glMultiTexCoord2fARB_fp)wglGetProcAddress("glMultiTexCoord2fARB");
|
||||
dglActiveTextureARB = (glActiveTextureARB_fp)wglGetProcAddress("glActiveTextureARB");
|
||||
|
@ -151,50 +141,25 @@ void ogl_get_verinfo(void)
|
|||
dglSelectTextureSGIS = (glSelectTextureSGIS_fp)wglGetProcAddress("glSelectTextureSGIS");
|
||||
#endif
|
||||
|
||||
ogl_ext_texture_filter_anisotropic_ok = (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic") != 0);
|
||||
if (ogl_ext_texture_filter_anisotropic_ok)
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic_max);
|
||||
|
||||
//add driver specific hacks here. whee.
|
||||
if ((stricmp(gl_renderer,"Mesa NVIDIA RIVA 1.0\n")==0 || stricmp(gl_renderer,"Mesa NVIDIA RIVA 1.2\n")==0) && stricmp(gl_version,"1.2 Mesa 3.0")==0){
|
||||
ogl_intensity4_ok=0;//ignores alpha, always black background instead of transparent.
|
||||
ogl_readpixels_ok=0;//either just returns all black, or kills the X server entirely
|
||||
ogl_gettexlevelparam_ok=0;//returns random data..
|
||||
GameArg.DbgGlIntensity4Ok=0;//ignores alpha, always black background instead of transparent.
|
||||
GameArg.DbgGlReadPixelsOk=0;//either just returns all black, or kills the X server entirely
|
||||
GameArg.DbgGlGetTexLevelParamOk=0;//returns random data..
|
||||
}
|
||||
if (stricmp(gl_vendor,"Matrox Graphics Inc.")==0){
|
||||
//displays garbage. reported by
|
||||
// redomen@crcwnet.com (render="Matrox G400" version="1.1.3 5.52.015")
|
||||
// orulz (Matrox G200)
|
||||
ogl_intensity4_ok=0;
|
||||
GameArg.DbgGlIntensity4Ok=0;
|
||||
}
|
||||
#ifdef macintosh
|
||||
if (stricmp(gl_renderer,"3dfx Voodoo 3")==0){ // strangely, includes Voodoo 2
|
||||
ogl_gettexlevelparam_ok=0; // Always returns 0
|
||||
GameArg.DbgGlGetTexLevelParamOk=0; // Always returns 0
|
||||
}
|
||||
#endif
|
||||
|
||||
//allow overriding of stuff.
|
||||
if ((t=FindArg("-gl_intensity4_ok"))){
|
||||
ogl_intensity4_ok=atoi(Args[t+1]);
|
||||
}
|
||||
if ((t=FindArg("-gl_luminance4_alpha4_ok"))){
|
||||
ogl_luminance4_alpha4_ok=atoi(Args[t+1]);
|
||||
}
|
||||
if ((t=FindArg("-gl_rgba2_ok"))){
|
||||
ogl_rgba2_ok=atoi(Args[t+1]);
|
||||
}
|
||||
if ((t=FindArg("-gl_readpixels_ok"))){
|
||||
ogl_readpixels_ok=atoi(Args[t+1]);
|
||||
}
|
||||
if ((t=FindArg("-gl_gettexlevelparam_ok"))){
|
||||
ogl_gettexlevelparam_ok=atoi(Args[t+1]);
|
||||
}
|
||||
if ((t=FindArg("-gl_setgammaramp_ok")))
|
||||
{
|
||||
ogl_setgammaramp_ok = atoi(Args[t + 1]);
|
||||
}
|
||||
|
||||
con_printf(CON_VERBOSE, "gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i gl_setgammaramp_ok:%i gl_ext_texture_filter_anisotropic:%i(%f max) gl_scissor:%i\n", ogl_intensity4_ok, ogl_luminance4_alpha4_ok, ogl_rgba2_ok, ogl_readpixels_ok, ogl_gettexlevelparam_ok, ogl_setgammaramp_ok, ogl_ext_texture_filter_anisotropic_ok, anisotropic_max,GameArg.OglScissorOk);
|
||||
con_printf(CON_VERBOSE, "gl_intensity4:%i gl_luminance4_alpha4:%i gl_rgba2:%i gl_readpixels:%i gl_gettexlevelparam:%i gl_setgammaramp_ok:%i gl_scissor:%i\n", GameArg.DbgGlIntensity4Ok, GameArg.DbgGlLuminance4Alpha4Ok, GameArg.DbgGlRGBA2Ok, GameArg.DbgGlReadPixelsOk, GameArg.DbgGlGetTexLevelParamOk, GameArg.DbgGlSetGammaRampOk, GameArg.OglScissorOk);
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,7 +273,7 @@ int ogl_init_load_library(void)
|
|||
|
||||
int gr_init(int mode)
|
||||
{
|
||||
int retcode, t;
|
||||
int retcode;
|
||||
|
||||
// Only do this function once!
|
||||
if (gr_installed==1)
|
||||
|
@ -323,17 +288,7 @@ int gr_init(int mode)
|
|||
|
||||
GL_needmipmaps=ogl_testneedmipmaps(GameArg.OglTexMinFilt);
|
||||
|
||||
if ((t = FindArg("-gl_anisotropy")) || (t = FindArg("-gl_anisotropic")))
|
||||
{
|
||||
GL_texanisofilt=atof(Args[t + 1]);
|
||||
}
|
||||
|
||||
mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GameArg.OglTexMagFilt,GameArg.OglTexMinFilt,GL_needmipmaps,GL_texanisofilt));
|
||||
|
||||
|
||||
if ((t=FindArg("-gl_vidmem"))){
|
||||
ogl_mem_target=atoi(Args[t+1])*1024*1024;
|
||||
}
|
||||
mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i\n",GameArg.OglTexMagFilt,GameArg.OglTexMinFilt,GL_needmipmaps));
|
||||
|
||||
ogl_init();//platform specific initialization
|
||||
|
||||
|
@ -467,7 +422,6 @@ void gr_palette_clear()
|
|||
|
||||
|
||||
int ogl_brightness_ok = 0;
|
||||
int ogl_setgammaramp_ok = 0;
|
||||
int ogl_brightness_r = 0, ogl_brightness_g = 0, ogl_brightness_b = 0;
|
||||
static int old_b_r = 0, old_b_g = 0, old_b_b = 0;
|
||||
|
||||
|
@ -484,13 +438,13 @@ void gr_palette_step_up(int r, int g, int b)
|
|||
ogl_brightness_g = max(g + gr_palette_gamma, 0);
|
||||
ogl_brightness_b = max(b + gr_palette_gamma, 0);
|
||||
|
||||
if (ogl_setgammaramp_ok &&
|
||||
if (GameArg.DbgGlSetGammaRampOk &&
|
||||
(old_b_r != ogl_brightness_r ||
|
||||
old_b_g != ogl_brightness_g ||
|
||||
old_b_b != ogl_brightness_b))
|
||||
ogl_brightness_ok = !ogl_setbrightness_internal();
|
||||
|
||||
if (!ogl_setgammaramp_ok || !ogl_brightness_ok)
|
||||
if (!GameArg.DbgGlSetGammaRampOk || !ogl_brightness_ok)
|
||||
{
|
||||
last_r = ogl_brightness_r / 63.0;
|
||||
last_g = ogl_brightness_g / 63.0;
|
||||
|
@ -600,7 +554,7 @@ void save_screen_shot(int automap_flag)
|
|||
char savename[13+sizeof(SCRNS_DIR)];
|
||||
unsigned char *buf;
|
||||
|
||||
if (!ogl_readpixels_ok){
|
||||
if (!GameArg.DbgGlReadPixelsOk){
|
||||
if (!automap_flag)
|
||||
hud_message(MSGC_GAME_FEEDBACK,"glReadPixels not supported on your configuration");
|
||||
return;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
extern ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE];
|
||||
|
||||
extern int ogl_mem_target;
|
||||
|
||||
void ogl_init_texture_list_internal(void);
|
||||
void ogl_smash_texture_list_internal(void);
|
||||
void ogl_vivify_texture_list_internal(void);
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
|
||||
unsigned char *ogl_pal=gr_palette;
|
||||
|
||||
float GL_texanisofilt = 0;
|
||||
int GL_needmipmaps=0;
|
||||
|
||||
int last_width=-1,last_height=-1;
|
||||
|
@ -81,12 +80,6 @@ int GL_texclamp_enabled=-1;
|
|||
int r_texcount = 0, r_cachedtexcount = 0;
|
||||
int ogl_rgba_internalformat = GL_RGBA8;
|
||||
int ogl_rgb_internalformat = GL_RGB8;
|
||||
int ogl_intensity4_ok=1;
|
||||
int ogl_luminance4_alpha4_ok=1;
|
||||
int ogl_rgba2_ok=1;
|
||||
int ogl_readpixels_ok=1;
|
||||
int ogl_gettexlevelparam_ok=1;
|
||||
int ogl_ext_texture_filter_anisotropic_ok = 0;
|
||||
int sphereh=0;
|
||||
int cross_lh[2]={0,0};
|
||||
int primary_lh[3]={0,0,0};
|
||||
|
@ -123,17 +116,17 @@ void ogl_init_texture(ogl_texture* t, int w, int h, int flags)
|
|||
// use GL_INTENSITY instead of GL_RGB
|
||||
if (flags & OGL_FLAG_ALPHA)
|
||||
{
|
||||
if (ogl_intensity4_ok)
|
||||
if (GameArg.DbgGlIntensity4Ok)
|
||||
{
|
||||
t->internalformat = GL_INTENSITY4;
|
||||
t->format = GL_LUMINANCE;
|
||||
}
|
||||
else if (ogl_luminance4_alpha4_ok)
|
||||
else if (GameArg.DbgGlLuminance4Alpha4Ok)
|
||||
{
|
||||
t->internalformat = GL_LUMINANCE4_ALPHA4;
|
||||
t->format = GL_LUMINANCE_ALPHA;
|
||||
}
|
||||
else if (ogl_rgba2_ok)
|
||||
else if (GameArg.DbgGlRGBA2Ok)
|
||||
{
|
||||
t->internalformat = GL_RGBA2;
|
||||
t->format = GL_RGBA;
|
||||
|
@ -271,27 +264,26 @@ int ogl_texture_stats(void){
|
|||
return truebytes;
|
||||
}
|
||||
|
||||
int ogl_mem_target=-1;
|
||||
void ogl_clean_texture_cache(void){
|
||||
ogl_texture* t;
|
||||
int i,bytes;
|
||||
int time=120;
|
||||
|
||||
if (ogl_mem_target<0){
|
||||
if (GameArg.DbgGlMemTarget<0){
|
||||
if (GameArg.DbgRenderStats)
|
||||
ogl_texture_stats();
|
||||
return;
|
||||
}
|
||||
|
||||
bytes=ogl_texture_stats();
|
||||
while (bytes>ogl_mem_target){
|
||||
while (bytes>GameArg.DbgGlMemTarget){
|
||||
for (i=0;i<OGL_TEXTURE_LIST_SIZE;i++){
|
||||
t=&ogl_texture_list[i];
|
||||
if (t->handle>0){
|
||||
if (t->lastrend+f1_0*time<GameTime){
|
||||
ogl_freetexture(t);
|
||||
bytes-=t->bytes;
|
||||
if (bytes<ogl_mem_target)
|
||||
if (bytes<GameArg.DbgGlMemTarget)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1025,13 +1017,13 @@ void gr_flip(void)
|
|||
int tex_format_supported(int iformat,int format){
|
||||
switch (iformat){
|
||||
case GL_INTENSITY4:
|
||||
if (!ogl_intensity4_ok) return 0; break;
|
||||
if (!GameArg.DbgGlIntensity4Ok) return 0; break;
|
||||
case GL_LUMINANCE4_ALPHA4:
|
||||
if (!ogl_luminance4_alpha4_ok) return 0; break;
|
||||
if (!GameArg.DbgGlLuminance4Alpha4Ok) return 0; break;
|
||||
case GL_RGBA2:
|
||||
if (!ogl_rgba2_ok) return 0; break;
|
||||
if (!GameArg.DbgGlRGBA2Ok) return 0; break;
|
||||
}
|
||||
if (ogl_gettexlevelparam_ok){
|
||||
if (GameArg.DbgGlGetTexLevelParamOk){
|
||||
GLint internalFormat;
|
||||
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, iformat, 64, 64, 0,
|
||||
format, GL_UNSIGNED_BYTE, texbuf);//NULL?
|
||||
|
@ -1189,13 +1181,13 @@ int tex_format_verify(ogl_texture *tex){
|
|||
glmprintf((0,"tex format %x not supported",tex->internalformat));
|
||||
switch (tex->internalformat){
|
||||
case GL_INTENSITY4:
|
||||
if (ogl_luminance4_alpha4_ok){
|
||||
if (GameArg.DbgGlLuminance4Alpha4Ok){
|
||||
tex->internalformat=GL_LUMINANCE4_ALPHA4;
|
||||
tex->format=GL_LUMINANCE_ALPHA;
|
||||
break;
|
||||
}//note how it will fall through here if the statement is false
|
||||
case GL_LUMINANCE4_ALPHA4:
|
||||
if (ogl_rgba2_ok){
|
||||
if (GameArg.DbgGlRGBA2Ok){
|
||||
tex->internalformat=GL_RGBA2;
|
||||
tex->format=GL_RGBA;
|
||||
break;
|
||||
|
@ -1236,7 +1228,7 @@ void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){
|
|||
void tex_set_size(ogl_texture *tex){
|
||||
GLint w,h;
|
||||
int bi=16,a=0;
|
||||
if (ogl_gettexlevelparam_ok){
|
||||
if (GameArg.DbgGlGetTexLevelParamOk){
|
||||
GLint t;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&w);
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&h);
|
||||
|
|
|
@ -275,7 +275,7 @@ int gr_init(int mode)
|
|||
sdl_video_flags|=SDL_FULLSCREEN;
|
||||
|
||||
//added 05/19/99 Matt Mueller - make HW surface optional
|
||||
if (FindArg("-hwsurface"))
|
||||
if (GameArg.DbgSdlHWSurface)
|
||||
sdl_video_flags|=SDL_HWSURFACE;
|
||||
//end addition -MM
|
||||
|
||||
|
|
|
@ -100,6 +100,15 @@ typedef struct Arg
|
|||
#ifdef OGL
|
||||
int DbgAltTexMerge;
|
||||
int DbgGlBpp;
|
||||
int DbgGlIntensity4Ok;
|
||||
int DbgGlLuminance4Alpha4Ok;
|
||||
int DbgGlRGBA2Ok;
|
||||
int DbgGlReadPixelsOk;
|
||||
int DbgGlGetTexLevelParamOk;
|
||||
int DbgGlSetGammaRampOk;
|
||||
int DbgGlMemTarget;
|
||||
#else
|
||||
int DbgSdlHWSurface;
|
||||
#endif
|
||||
} __attribute__ ((packed)) Arg;
|
||||
|
||||
|
|
|
@ -59,25 +59,11 @@ void ogl_init_texture(ogl_texture* t, int w, int h, int flags);
|
|||
|
||||
extern int ogl_rgba_internalformat;
|
||||
extern int ogl_rgb_internalformat;
|
||||
extern int ogl_setgammaramp_ok;
|
||||
extern int ogl_intensity4_ok;
|
||||
extern int ogl_luminance4_alpha4_ok;
|
||||
extern int ogl_rgba2_ok;
|
||||
extern int ogl_readpixels_ok;
|
||||
extern int ogl_gettexlevelparam_ok;
|
||||
|
||||
#ifndef GL_EXT_texture_filter_anisotropic
|
||||
#define GL_EXT_texture_filter_anisotropic 1
|
||||
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
#endif
|
||||
extern int ogl_ext_texture_filter_anisotropic_ok;
|
||||
|
||||
void ogl_init_shared_palette(void);
|
||||
|
||||
extern int gl_initialized;
|
||||
extern int GL_needmipmaps;
|
||||
extern float GL_texanisofilt;
|
||||
|
||||
extern int active_texture_unit;
|
||||
void ogl_setActiveTexture(int t);
|
||||
|
|
|
@ -243,6 +243,15 @@ void print_commandline_help()
|
|||
#ifdef OGL
|
||||
printf( " -gl_oldtexmerge %s\n", "Use old texmerge, uses more ram, but _might_ be a bit faster");
|
||||
printf( " -gl_16bpp %s\n", "Use 16Bpp Color Depth");
|
||||
printf( " -gl_intensity4_ok <n> %s\n", "Override DbgGlIntensity4Ok - Default: 1");
|
||||
printf( " -gl_luminance4_alpha4_ok <n> %s\n", "Override DbgGlLuminance4Alpha4Ok - Default: 1");
|
||||
printf( " -gl_rgba2_ok <n> %s\n", "Override DbgGlRGBA2Ok - Default: 1");
|
||||
printf( " -gl_readpixels_ok <n> %s\n", "Override DbgGlReadPixelsOk - Default: 1");
|
||||
printf( " -gl_gettexlevelparam_ok <n> %s\n", "Override DbgGlGetTexLevelParamOk - Default: 1");
|
||||
printf( " -gl_setgammaramp_ok <n> %s\n", "Override DbgGlSetGammaRampOk - Default: 0");
|
||||
printf( " -gl_vidmem <n> %s\n", "Limit Texture cache to <n> MB");
|
||||
#else
|
||||
printf( " -hwsurface %s\n", "Use HW Surface");
|
||||
#endif
|
||||
|
||||
/* KEPT FOR FURTHER REFERENCE
|
||||
|
@ -254,10 +263,7 @@ void print_commandline_help()
|
|||
printf( " -vidram %s\n", "FIXME: Undocumented");
|
||||
printf( " -xname %s\n", "FIXME: Undocumented");
|
||||
printf( " -xver %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_intensity4_ok %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_luminance4_alpha4_ok %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_readpixels_ok %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_rgba2_ok %s\n", "FIXME: Undocumented");
|
||||
|
||||
printf( " -gl_test1 %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_test2 %s\n", "FIXME: Undocumented");
|
||||
printf( " -gl_vidmem %s\n", "FIXME: Undocumented");
|
||||
|
|
40
misc/args.c
40
misc/args.c
|
@ -438,6 +438,46 @@ void ReadCmdArgs(void)
|
|||
GameArg.DbgGlBpp = 16;
|
||||
else
|
||||
GameArg.DbgGlBpp = 32;
|
||||
|
||||
if ((t=FindArg("-gl_intensity4_ok")))
|
||||
GameArg.DbgGlIntensity4Ok = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlIntensity4Ok = 1;
|
||||
|
||||
if ((t=FindArg("-gl_luminance4_alpha4_ok")))
|
||||
GameArg.DbgGlLuminance4Alpha4Ok = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlLuminance4Alpha4Ok = 1;
|
||||
|
||||
if ((t=FindArg("-gl_rgba2_ok")))
|
||||
GameArg.DbgGlRGBA2Ok = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlRGBA2Ok = 1;
|
||||
|
||||
if ((t=FindArg("-gl_readpixels_ok")))
|
||||
GameArg.DbgGlReadPixelsOk = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlReadPixelsOk = 1;
|
||||
|
||||
if ((t=FindArg("-gl_gettexlevelparam_ok")))
|
||||
GameArg.DbgGlGetTexLevelParamOk = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlGetTexLevelParamOk = 1;
|
||||
|
||||
if ((t=FindArg("-gl_setgammaramp_ok")))
|
||||
GameArg.DbgGlSetGammaRampOk = atoi(Args[t+1]);
|
||||
else
|
||||
GameArg.DbgGlSetGammaRampOk = 0;
|
||||
|
||||
if ((t=FindArg("-gl_vidmem")))
|
||||
GameArg.DbgGlMemTarget = atoi(Args[t+1])*1024*1024;
|
||||
else
|
||||
GameArg.DbgGlMemTarget = -1;
|
||||
#else
|
||||
if (FindArg("-hwsurface"))
|
||||
GameArg.DbgSdlHWSurface = 1;
|
||||
else
|
||||
GameArg.DbgSdlHWSurface = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue