Simplified ogl version of gr.c in terms of SDL video flags and fullscreen toggle; Added command-line/INI option to remove borders from windowed program
This commit is contained in:
parent
be7713c1ae
commit
6bc439a343
|
@ -3,6 +3,7 @@ D1X-Rebirth Changelog
|
|||
20110210
|
||||
--------
|
||||
main/automap.c, main/gauges.c, main/gauges.h, main/kconfig.c, main/newmenu.c, main/newmenu.h: Fixed broken FlightSim indicator on Automap; Fixed Assert for using mouse buttons in kconfig (which can react to UP and DOWN states); Added scrolling support for menus flagged tiny_mode and all_text
|
||||
arch/ogl/gr.c, arch/sdl/gr.c, d1x.ini, include/args.h, main/inferno.c, misc/args.c: Simplified ogl version of gr.c in terms of SDL video flags and fullscreen toggle; Added command-line/INI option to remove borders from windowed program
|
||||
|
||||
20110209
|
||||
--------
|
||||
|
|
|
@ -60,10 +60,13 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OGLES
|
||||
int sdl_video_flags = 0;
|
||||
#else
|
||||
int sdl_video_flags = SDL_OPENGL;
|
||||
#endif
|
||||
int gr_installed = 0;
|
||||
int gl_initialized=0;
|
||||
int ogl_fullscreen=0;
|
||||
static int curx=-1,cury=-1,curfull=0;
|
||||
int linedotscale=1; // scalar of glLinewidth and glPointSize - only calculated once when resolution changes
|
||||
|
||||
#ifdef OGLES
|
||||
|
@ -110,20 +113,18 @@ int ogl_init_window(int x, int y)
|
|||
int iConfigs;
|
||||
#endif
|
||||
|
||||
if (gl_initialized){
|
||||
if (x==curx && y==cury && curfull==ogl_fullscreen)
|
||||
return 0;
|
||||
if (gl_initialized)
|
||||
ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption(DESCENT_VERSION, "Descent");
|
||||
SDL_WM_SetIcon( SDL_LoadBMP( "d1x-rebirth.bmp" ), NULL );
|
||||
#ifdef OGLES
|
||||
if (!SDL_SetVideoMode(x, y, GameArg.DbgBpp, (ogl_fullscreen ? SDL_FULLSCREEN : 0)))
|
||||
|
||||
if (!SDL_SetVideoMode(x, y, GameArg.DbgBpp, sdl_video_flags))
|
||||
{
|
||||
Error("Could not set %dx%dx%d opengl video mode: %s\n", x, y, GameArg.DbgBpp, SDL_GetError());
|
||||
}
|
||||
|
||||
#ifdef OGLES
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if (SDL_GetWMInfo(&info) > 0) {
|
||||
|
@ -167,15 +168,7 @@ int ogl_init_window(int x, int y)
|
|||
} else {
|
||||
con_printf(CON_URGENT, "EGL: Created current\n");
|
||||
}
|
||||
#else
|
||||
if (!SDL_SetVideoMode(x, y, GameArg.DbgBpp, SDL_OPENGL | (ogl_fullscreen ? SDL_FULLSCREEN : 0)))
|
||||
{
|
||||
Error("Could not set %dx%dx%d opengl video mode: %s\n", x, y, GameArg.DbgBpp, SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
SDL_ShowCursor(0);
|
||||
|
||||
curx=x;cury=y;curfull=ogl_fullscreen;
|
||||
|
||||
linedotscale = ((x/640<y/480?x/640:y/480)<1?1:(x/640<y/480?x/640:y/480));
|
||||
|
||||
|
@ -185,33 +178,28 @@ int ogl_init_window(int x, int y)
|
|||
|
||||
int gr_check_fullscreen(void)
|
||||
{
|
||||
return ogl_fullscreen;
|
||||
}
|
||||
|
||||
void gr_do_fullscreen(int f)
|
||||
{
|
||||
ogl_fullscreen=f;
|
||||
if (gl_initialized)
|
||||
{
|
||||
if (!SDL_VideoModeOK(curx, cury, GameArg.DbgBpp,
|
||||
#ifndef OGLES
|
||||
SDL_OPENGL |
|
||||
#endif
|
||||
(ogl_fullscreen?SDL_FULLSCREEN:0)))
|
||||
{
|
||||
con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",curx,cury);
|
||||
curx=640;
|
||||
cury=480;
|
||||
Game_screen_mode=SM(curx,cury);
|
||||
}
|
||||
|
||||
ogl_init_window(curx,cury);
|
||||
}
|
||||
return (sdl_video_flags & SDL_FULLSCREEN)?1:0;
|
||||
}
|
||||
|
||||
int gr_toggle_fullscreen(void)
|
||||
{
|
||||
gr_do_fullscreen(!ogl_fullscreen);
|
||||
if (sdl_video_flags & SDL_FULLSCREEN)
|
||||
sdl_video_flags &= ~SDL_FULLSCREEN;
|
||||
else
|
||||
sdl_video_flags |= SDL_FULLSCREEN;
|
||||
|
||||
if (gl_initialized)
|
||||
{
|
||||
if (!SDL_VideoModeOK(SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, sdl_video_flags))
|
||||
{
|
||||
con_printf(CON_URGENT,"Cannot set %ix%i. Fallback to 640x480\n",SM_W(Game_screen_mode), SM_H(Game_screen_mode));
|
||||
Game_screen_mode=SM(640,480);
|
||||
}
|
||||
if (!SDL_SetVideoMode(SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, sdl_video_flags))
|
||||
{
|
||||
Error("Could not set %dx%dx%d opengl video mode: %s\n", SM_W(Game_screen_mode), SM_H(Game_screen_mode), GameArg.DbgBpp, SDL_GetError());
|
||||
}
|
||||
}
|
||||
|
||||
if (gl_initialized) // update viewing values for menus
|
||||
{
|
||||
|
@ -227,8 +215,8 @@ int gr_toggle_fullscreen(void)
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
GameCfg.WindowMode = !ogl_fullscreen;
|
||||
return ogl_fullscreen;
|
||||
GameCfg.WindowMode = (sdl_video_flags & SDL_FULLSCREEN)?0:1;
|
||||
return (sdl_video_flags & SDL_FULLSCREEN)?1:0;
|
||||
}
|
||||
|
||||
extern void ogl_init_pixel_buffers(int w, int h);
|
||||
|
@ -340,7 +328,7 @@ int gr_list_modes( u_int32_t gsmodes[] )
|
|||
{
|
||||
for (i = 0; modes[i]; ++i)
|
||||
{
|
||||
if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (kreatordxx - made 0xFFF0 to kill warning)
|
||||
if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (changed to 0xFFF0 to fix warning)
|
||||
|| modes[i]->w < 320 || modes[i]->h < 200) // also skip everything smaller than 320x200
|
||||
continue;
|
||||
gsmodes[modesnum] = SM(modes[i]->w,modes[i]->h);
|
||||
|
@ -359,11 +347,7 @@ int gr_check_mode(u_int32_t mode)
|
|||
w=SM_W(mode);
|
||||
h=SM_H(mode);
|
||||
|
||||
return SDL_VideoModeOK(w, h, GameArg.DbgBpp,
|
||||
#ifndef OGLES
|
||||
SDL_OPENGL |
|
||||
#endif
|
||||
(ogl_fullscreen?SDL_FULLSCREEN:0));
|
||||
return SDL_VideoModeOK(w, h, GameArg.DbgBpp, sdl_video_flags);
|
||||
}
|
||||
|
||||
int gr_set_mode(u_int32_t mode)
|
||||
|
@ -489,7 +473,10 @@ int gr_init(int mode)
|
|||
#endif
|
||||
|
||||
if (!GameCfg.WindowMode && !GameArg.SysWindow)
|
||||
gr_toggle_fullscreen();
|
||||
sdl_video_flags|=SDL_FULLSCREEN;
|
||||
|
||||
if (GameArg.SysNoBorders)
|
||||
sdl_video_flags|=SDL_NOFRAME;
|
||||
|
||||
gr_set_attributes();
|
||||
|
||||
|
@ -524,7 +511,6 @@ void gr_close()
|
|||
if (gl_initialized)
|
||||
{
|
||||
ogl_smash_texture_list_internal();
|
||||
SDL_ShowCursor(1);
|
||||
}
|
||||
|
||||
if (grd_curscreen)
|
||||
|
|
|
@ -184,6 +184,9 @@ int gr_init(int mode)
|
|||
if (!GameCfg.WindowMode && !GameArg.SysWindow)
|
||||
sdl_video_flags|=SDL_FULLSCREEN;
|
||||
|
||||
if (GameArg.SysNoBorders)
|
||||
sdl_video_flags|=SDL_NOFRAME;
|
||||
|
||||
if (GameArg.DbgSdlHWSurface)
|
||||
sdl_video_flags|=SDL_HWSURFACE;
|
||||
|
||||
|
|
1
d1x.ini
1
d1x.ini
|
@ -11,6 +11,7 @@
|
|||
;-autodemo Start in demo mode
|
||||
;-notitles Skip title screens
|
||||
;-window Run the game in a window
|
||||
;-noborders Do not show borders in window mode
|
||||
|
||||
Controls:
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef struct Arg
|
|||
int SysLowMem;
|
||||
char *SysPilot;
|
||||
int SysWindow;
|
||||
int SysNoBorders;
|
||||
int SysAutoDemo;
|
||||
int SysNoTitles;
|
||||
int CtlNoMouse;
|
||||
|
|
|
@ -114,6 +114,7 @@ void print_commandline_help()
|
|||
printf( " -autodemo %s\n", "Start in demo mode");
|
||||
printf( " -notitles %s\n", "Skip title screens");
|
||||
printf( " -window %s\n", "Run the game in a window");
|
||||
printf( " -noborders %s\n", "Do not show borders in window mode");
|
||||
|
||||
printf( "\n Controls:\n\n");
|
||||
printf( " -nomouse %s\n", "Deactivate mouse");
|
||||
|
|
|
@ -138,6 +138,7 @@ void ReadCmdArgs(void)
|
|||
GameArg.SysLowMem = FindArg("-lowmem");
|
||||
GameArg.SysPilot = get_str_arg("-pilot", NULL);
|
||||
GameArg.SysWindow = FindArg("-window");
|
||||
GameArg.SysNoBorders = FindArg("-noborders");
|
||||
GameArg.SysNoTitles = FindArg("-notitles");
|
||||
GameArg.SysAutoDemo = FindArg("-autodemo");
|
||||
|
||||
|
|
Loading…
Reference in a new issue