From dea4e2426106ed2b46c3799c7b34a358a4c303aa Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 4 Feb 2019 21:51:00 +0300 Subject: [PATCH] Added BPP switching --- src/game/g_menu.pas | 27 +++++++++++++++++++-------- src/nogl/noGLALSW.inc | 6 +++--- src/wrappers/sdl2/sdl2allegro.inc | 14 +++++++------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 5df0bf1..d720619 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -111,10 +111,14 @@ var begin menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu')); - if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then - gBPP := 16 - else - gBPP := 32; + case TGUISwitch(menu.GetControl('swBPP')).ItemIndex of + 0: gBPP := 8; + 1: gBPP := 15; + 2: gBPP := 16; + 3: gBPP := 24; + 4: gBPP := 32; + else gBPP := 32 + end; ovs := gVSync; gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0; @@ -330,10 +334,14 @@ begin menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu')); with TGUISwitch(menu.GetControl('swBPP')) do - if gBPP = 16 then - ItemIndex := 0 - else - ItemIndex := 1; + case gBPP of + 8: ItemIndex := 0; + 15: ItemIndex := 1; + 16: ItemIndex := 2; + 24: ItemIndex := 3; + 32: ItemIndex := 4; + else ItemIndex := 4 + end; with TGUISwitch(menu.GetControl('swTextureFilter')) do if gTextureFilter then ItemIndex := 0 else ItemIndex := 1; @@ -2513,7 +2521,10 @@ begin with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do begin Name := 'swBPP'; + AddItem('8'); + AddItem('15'); AddItem('16'); + AddItem('24'); AddItem('32'); end; with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do diff --git a/src/nogl/noGLALSW.inc b/src/nogl/noGLALSW.inc index bec8350..e06b9c3 100644 --- a/src/nogl/noGLALSW.inc +++ b/src/nogl/noGLALSW.inc @@ -200,7 +200,7 @@ implementation BLEND_DEFAULT: begin (* FIX texture colorize *) - if DEFAULT_DEPTH <= 8 then + if sdl2allegro_bpp <= 8 then begin drawing_mode(DRAW_MODE_SOLID, nil, 0, 0) end @@ -663,7 +663,7 @@ implementation p := pixels; if format = GL_RGBA then begin - if DEFAULT_DEPTH <= 8 then + if sdl2allegro_bpp <= 8 then trans := 0 else trans := makeacol(255, 0, 255, 0); @@ -710,7 +710,7 @@ implementation p := pixels; if format = GL_RGBA then begin - if DEFAULT_DEPTH <= 8 then + if sdl2allegro_bpp <= 8 then trans := 0 else trans := makeacol(255, 0, 255, 0); diff --git a/src/wrappers/sdl2/sdl2allegro.inc b/src/wrappers/sdl2/sdl2allegro.inc index 9f146dd..a1f7393 100644 --- a/src/wrappers/sdl2/sdl2allegro.inc +++ b/src/wrappers/sdl2/sdl2allegro.inc @@ -9,9 +9,6 @@ interface {$I sdlpixels.inc} {$I sdlscancode.inc} - const - DEFAULT_DEPTH = 8; - const SDL_HAT_CENTERED = $00; SDL_HAT_UP = $01; @@ -298,6 +295,7 @@ interface var sdl2allegro_screen: PBITMAP; + sdl2allegro_bpp: Integer; /// FUNCTIONS /// @@ -369,7 +367,7 @@ implementation {$IFDEF GO32V2} go32, {$ENDIF} - e_Log, SysUtils, ctypes; + e_Log, g_options, SysUtils, ctypes; const maxKeyBuffer = 64; @@ -923,7 +921,8 @@ implementation mode := GFX_AUTODETECT_WINDOWED; {$ENDIF} - set_color_depth(DEFAULT_DEPTH); + sdl2allegro_bpp := gBPP; + set_color_depth(sdl2allegro_bpp); if set_gfx_mode(mode, w, h, 0, 0) = 0 then begin new(window); @@ -957,7 +956,7 @@ implementation mode := GFX_AUTODETECT_WINDOWED; {$ENDIF} - set_color_depth(DEFAULT_DEPTH); + set_color_depth(sdl2allegro_bpp); if set_gfx_mode(mode, window.w, window.h, 0, 0) = 0 then begin if sdl2allegro_screen <> nil then @@ -976,7 +975,8 @@ implementation begin e_LogWritefln('SDL_SetWindowSize %s %s', [w, h]); if window = nil then exit; - set_color_depth(DEFAULT_DEPTH); + + set_color_depth(sdl2allegro_bpp); if set_gfx_mode(window.mode, w, h, 0, 0) = 0 then begin if sdl2allegro_screen <> nil then -- 2.29.2