Added function gr_set_attributes to change Options like Texture Filtering and SDL_GL attributes while runtime (if supported); Added 4x Multisample support

This commit is contained in:
zicodxx 2008-04-22 08:29:29 +00:00
parent 410dadb7c9
commit 5d19c11124
7 changed files with 63 additions and 31 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20080422
--------
arch/ogl/gr.c, arch/sdl/gr.c, include/gr.h, main/config.c, main/config.h, main/menu.c: Added function gr_set_attributes to change Options like Texture Filtering and SDL_GL attributes while runtime (if supported); Added 4x Multisample support
20080421
--------
main/console.c, main/inferno.c, main/menu.c, main/config.c, main/config.h, main/gamerend.c, main/game.c, main/gamecntl.c, misc/args.c, d2x.ini, arch/ogl/gr.c, arch/sdl/timer.c, arch/win32/netdrv_ipx.c: Reworked timer_delay2() and calc_frame_time() to be more accurate and CPU-friendly; -nicefps replayced by -nonicefps to disable sleeping for calc_frame_time; Implemented VSync via SDL; Fixed compilation issues; Code cleanup

View file

@ -303,21 +303,8 @@ int ogl_init_load_library(void)
}
#endif
int gr_init(int mode)
void gr_set_attributes(void)
{
int retcode;
// Only do this function once!
if (gr_installed==1)
return -1;
#ifdef _WIN32
ogl_init_load_library();
#endif
if (!GameCfg.WindowMode && !GameArg.SysWindow)
gr_toggle_fullscreen();
switch (GameCfg.TexFilt)
{
case 2:
@ -344,9 +331,38 @@ int gr_init(int mode)
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,GameCfg.VSync);
if (GameCfg.Multisample)
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
}
else
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
ogl_smash_texture_list_internal();
}
int gr_init(int mode)
{
int retcode;
// Only do this function once!
if (gr_installed==1)
return -1;
#ifdef _WIN32
ogl_init_load_library();
#endif
if (!GameCfg.WindowMode && !GameArg.SysWindow)
gr_toggle_fullscreen();
gr_set_attributes();
ogl_init_texture_list_internal();
MALLOC( grd_curscreen,grs_screen,1 );
memset( grd_curscreen, 0, sizeof(grs_screen));
grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;

View file

@ -108,6 +108,10 @@ int gr_toggle_fullscreen(void)
return (sdl_video_flags & SDL_FULLSCREEN)?1:0;
}
void gr_set_attributes(void)
{
}
int gr_init(int mode)
{
int retcode;

View file

@ -166,6 +166,7 @@ int gr_init(int mode);
int gr_init_screen(int mode, int w, int h, int x, int y, int rowsize, ubyte *data);
int gr_set_mode(u_int32_t mode);
void gr_set_attributes(void);
extern void gr_pal_setblock( int start, int number, unsigned char * pal );
extern void gr_pal_getblock( int start, int number, unsigned char * pal );

View file

@ -64,6 +64,7 @@ static char *AspectYStr="AspectY";
static char *WindowModeStr="WindowMode";
static char *TexFiltStr="TexFilt";
static char *VSyncStr="VSync";
static char *MultisampleStr="Multisample";
int ReadConfigFile()
{
@ -85,6 +86,7 @@ int ReadConfigFile()
GameCfg.WindowMode = 0;
GameCfg.TexFilt = 0;
GameCfg.VSync = 0;
GameCfg.Multisample = 0;
infile = PHYSFSX_openReadBuffered("descent.cfg");
@ -142,6 +144,8 @@ int ReadConfigFile()
GameCfg.TexFilt = strtol(value, NULL, 10);
else if (!strcmp(token, VSyncStr))
GameCfg.VSync = strtol(value, NULL, 10);
else if (!strcmp(token, MultisampleStr))
GameCfg.Multisample = strtol(value, NULL, 10);
}
}
@ -185,6 +189,7 @@ int WriteConfigFile()
PHYSFSX_printf(infile, "%s=%i\n", WindowModeStr, GameCfg.WindowMode);
PHYSFSX_printf(infile, "%s=%i\n", TexFiltStr, GameCfg.TexFilt);
PHYSFSX_printf(infile, "%s=%i\n", VSyncStr, GameCfg.VSync);
PHYSFSX_printf(infile, "%s=%i\n", MultisampleStr, GameCfg.Multisample);
PHYSFS_close(infile);

View file

@ -40,6 +40,7 @@ typedef struct Cfg
int WindowMode;
int TexFilt;
int VSync;
int Multisample;
} __attribute__ ((packed)) Cfg;
extern struct Cfg GameCfg;

View file

@ -703,28 +703,29 @@ void do_graphics_menu()
do {
m[0].type = NM_TYPE_TEXT; m[0].text="Texture Filtering:";
m[1].type = NM_TYPE_TEXT; m[1].text=" (requires restart)";
m[2].type = NM_TYPE_RADIO; m[2].text = "None (Classical)"; m[2].value = 0; m[2].group = 0;
m[3].type = NM_TYPE_RADIO; m[3].text = "Bilinear"; m[3].value = 0; m[3].group = 0;
m[4].type = NM_TYPE_RADIO; m[4].text = "Trilinear"; m[4].value = 0; m[4].group = 0;
m[5].type = NM_TYPE_TEXT; m[5].text="";
m[6].type = NM_TYPE_CHECK; m[6].text="Transparency Effects"; m[6].value = PlayerCfg.OglAlphaEffects;
m[7].type = NM_TYPE_CHECK; m[7].text="Vectorial Reticle"; m[7].value = PlayerCfg.OglReticle;
m[8].type = NM_TYPE_CHECK; m[8].text="Screenshots w/o HUD"; m[8].value = PlayerCfg.OglPRShot;
m[9].type = NM_TYPE_CHECK; m[9].text="VSync (requires restart)"; m[9].value = GameCfg.VSync;
m[1].type = NM_TYPE_RADIO; m[1].text = "None (Classical)"; m[1].value = 0; m[1].group = 0;
m[2].type = NM_TYPE_RADIO; m[2].text = "Bilinear"; m[2].value = 0; m[2].group = 0;
m[3].type = NM_TYPE_RADIO; m[3].text = "Trilinear"; m[3].value = 0; m[3].group = 0;
m[4].type = NM_TYPE_TEXT; m[4].text="";
m[5].type = NM_TYPE_CHECK; m[5].text="Transparency Effects"; m[5].value = PlayerCfg.OglAlphaEffects;
m[6].type = NM_TYPE_CHECK; m[6].text="Vectorial Reticle"; m[6].value = PlayerCfg.OglReticle;
m[7].type = NM_TYPE_CHECK; m[7].text="Screenshots w/o HUD"; m[7].value = PlayerCfg.OglPRShot;
m[8].type = NM_TYPE_CHECK; m[8].text="VSync"; m[8].value = GameCfg.VSync;
m[9].type = NM_TYPE_CHECK; m[9].text="4x multisampling"; m[9].value = GameCfg.Multisample;
m[GameCfg.TexFilt+2].value=1;
m[GameCfg.TexFilt+1].value=1;
i = newmenu_do1( NULL, "Graphics Options", sizeof(m)/sizeof(*m), m, NULL, i );
for (j = 0; j <= 2; j++)
if (m[j+2].value)
if (m[j+1].value)
GameCfg.TexFilt = j;
PlayerCfg.OglAlphaEffects = m[6].value;
PlayerCfg.OglReticle = m[7].value;
PlayerCfg.OglPRShot = m[8].value;
GameCfg.VSync = m[9].value;
PlayerCfg.OglAlphaEffects = m[5].value;
PlayerCfg.OglReticle = m[6].value;
PlayerCfg.OglPRShot = m[7].value;
GameCfg.VSync = m[8].value;
GameCfg.Multisample = m[9].value;
gr_set_attributes();
} while( i>-1 );
}