From 6bc439a3435e3389110b7151036c89bb5b5a0031 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Thu, 10 Feb 2011 15:30:05 +0100 Subject: [PATCH] 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 --- CHANGELOG.txt | 1 + arch/ogl/gr.c | 88 +++++++++++++++++++++----------------------------- arch/sdl/gr.c | 3 ++ d1x.ini | 1 + include/args.h | 1 + main/inferno.c | 1 + misc/args.c | 1 + 7 files changed, 45 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 97ecb7fb2..8c7684ed9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 -------- diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index ac988702b..8aef4c1c2 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -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 @@ -109,21 +112,19 @@ int ogl_init_window(int x, int y) EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; 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/640w > 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) diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 82e716e13..38aa43f1e 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -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; diff --git a/d1x.ini b/d1x.ini index 0bdace317..fb2c14d21 100644 --- a/d1x.ini +++ b/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: diff --git a/include/args.h b/include/args.h index 627f2e43d..ffd7b3d24 100644 --- a/include/args.h +++ b/include/args.h @@ -50,6 +50,7 @@ typedef struct Arg int SysLowMem; char *SysPilot; int SysWindow; + int SysNoBorders; int SysAutoDemo; int SysNoTitles; int CtlNoMouse; diff --git a/main/inferno.c b/main/inferno.c index 719557507..f4a72e9a7 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -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"); diff --git a/misc/args.c b/misc/args.c index 243721d96..b876fdaa1 100644 --- a/misc/args.c +++ b/misc/args.c @@ -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");