From: Ketmar Dark Date: Fri, 18 Oct 2019 04:41:42 +0000 (+0300) Subject: gfx: fixed OpenGL extension checks; fixed NPOT emulation detection X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=7f50d798c193f8a57a3c736c81615ef932915e9a gfx: fixed OpenGL extension checks; fixed NPOT emulation detection --- diff --git a/src/game/g_language.pas b/src/game/g_language.pas index af65be7..2424efd 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -1127,8 +1127,8 @@ const 'Âåðòèêàëüíàÿ ñèíõðîíèçàöèÿ:'), ('MENU VIDEO FILTER SKY', 'Anisotropic sky', 'Ôèëüòðàöèÿ íåáà:'), - ('MENU VIDEO LEGACY COMPATIBLE', 'Compatibility with NPOT textures:', - 'Ñîâìåñòèìîñòü ñ NPOT-òåêñòóðàìè:'), + ('MENU VIDEO LEGACY COMPATIBLE', 'Force compatibility with NPOT textures:', + 'Ýìóëÿöèÿ NPOT-òåêñòóð:'), ('MENU VIDEO NEED RESTART', 'Video settings will be changed after game restart.', 'Äàííûå íàñòðîéêè âèäåî âñòóïÿò â ñèëó ïîñëå ïåðåçàïóñêà èãðû.'), diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 0269a4c..4543261 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -204,12 +204,12 @@ begin e_WriteLog('Releasing engine', TMsgType.Notify); e_ReleaseEngine(); - e_WriteLog('Releasing Input', TMsgType.Notify); + e_WriteLog('Releasing input', TMsgType.Notify); e_ReleaseInput(); if not gNoSound then begin - e_WriteLog('Releasing FMOD', TMsgType.Notify); + e_WriteLog('Releasing sound', TMsgType.Notify); e_ReleaseSoundSystem(); end; end; diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 2d83a52..ccc0a55 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -122,7 +122,7 @@ begin sys_EnableVSync(gVSync); gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0; - glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0); + glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0); menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu')); @@ -398,7 +398,7 @@ begin if gVSync then ItemIndex := 0 else ItemIndex := 1; with TGUISwitch(menu.GetControl('swLegacyNPOT')) do - if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1; + if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1; menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu')); diff --git a/src/game/g_options.pas b/src/game/g_options.pas index a80d682..1c23bb8 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -91,6 +91,7 @@ var gSFSFastMode: Boolean; gDefaultMegawadStart: AnsiString; gBerserkAutoswitch: Boolean; + glNPOTOverride: Boolean = false; implementation @@ -380,7 +381,7 @@ begin ReadInteger(gFreq, 'Freq', 0); ReadBoolean(gVSync, 'VSync'); ReadBoolean(gTextureFilter, 'TextureFilter'); - ReadBoolean(glLegacyNPOT, 'LegacyCompatible'); + ReadBoolean(glNPOTOverride, 'LegacyCompatibleForce'); section := 'Sound'; ReadBoolean(gNoSound, 'NoSound'); @@ -564,7 +565,7 @@ begin config.WriteInt('Video', 'BPP', gBPP); config.WriteBool('Video', 'VSync', gVSync); config.WriteBool('Video', 'TextureFilter', gTextureFilter); - config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT); + config.WriteBool('Video', 'LegacyCompatibleForce', glNPOTOverride); config.WriteBool('Sound', 'NoSound', gNoSound); config.WriteInt('Sound', 'SoundLevel', gSoundLevel); diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 8e6bbe8..afc23e2 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -184,36 +184,42 @@ begin end; function GLExtensionList (): SSArray; - var s: PChar; i, j, num: GLint; +var + s: PChar; + i, j, num: GLint; begin result := nil; s := glGetString(GL_EXTENSIONS); if s <> nil then begin - num := 0; i := 0; j := 0; - while s[i] <> #0 do + num := 0; + i := 0; + j := 0; + while (s[i] <> #0) and (s[i] = ' ') do Inc(i); + while (s[i] <> #0) do begin while (s[i] <> #0) and (s[i] <> ' ') do Inc(i); - SetLength(result, num + 1); - result[num] := Copy(s, j, i - j); + SetLength(result, num+1); + result[num] := Copy(s, j+1, i-j); while (s[i] <> #0) and (s[i] = ' ') do Inc(i); j := i; - Inc(num) - end - end + Inc(num); + end; + end; end; function GLExtensionSupported (ext: AnsiString): Boolean; - var i, len: GLint; exts: SSArray; +var + exts: SSArray; + e: AnsiString; begin result := false; exts := GLExtensionList(); - if exts <> nil then + for e in exts do begin - i := 0; len := Length(exts); - while (i < len) and (exts[i] <> ext) do Inc(i); - result := i < len - end + //writeln('<', e, '> : [', ext, '] = ', strEquCI1251(e, ext)); + if (strEquCI1251(e, ext)) then begin result := true; exit; end; + end; end; procedure PrintGLSupportedExtensions; @@ -324,11 +330,20 @@ begin {$IFNDEF USE_SYSSTUB} PrintGLSupportedExtensions; - glLegacyNPOT := GLExtensionSupported('GL_ARB_texture_non_power_of_two') or GLExtensionSupported('GL_OES_texture_npot'); + glLegacyNPOT := not (GLExtensionSupported('GL_ARB_texture_non_power_of_two') or GLExtensionSupported('GL_OES_texture_npot')); {$ELSE} glLegacyNPOT := False; {$ENDIF} - e_logWritefln('NPOT textures: %s', [glLegacyNPOT]); + if glNPOTOverride and glLegacyNPOT then + begin + glLegacyNPOT := true; + e_logWriteln('NPOT texture emulation: FORCED'); + end + else + begin + if (glLegacyNPOT) then e_logWriteln('NPOT texture emulation: enabled') + else e_logWriteln('NPOT texture emulation: disabled'); + end; gwin_dump_extensions := false; Init;