X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_window.pas;h=6dfa778096ff33f616b553c00539c81b542227fd;hb=ebb13957295d3f50ba51ff5b871310570d0d4dfe;hp=5e7e926727f3989e0db09c1867e9750930e65c0b;hpb=ea2a0471121aabe9ff059e29c1c42fa313307c23;p=d2df-sdl.git diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 5e7e926..6dfa778 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -1,3 +1,18 @@ +(* Copyright (C) DooM 2D:Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) {$MODE DELPHI} unit g_window; @@ -21,6 +36,10 @@ function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SArray; function g_Window_SetDisplay(PreserveGL: Boolean = False): Boolean; function g_Window_SetSize(W, H: Word; FScreen: Boolean): Boolean; +var + gwin_dump_extensions: Boolean = false; + gwin_has_stencil: Boolean = false; + implementation uses @@ -622,15 +641,63 @@ begin SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); // lights; it is enough to have 1-bit stencil buffer for lighting SDL_GL_SetSwapInterval(v); end; +function glHasExtension (name: AnsiString): Boolean; +var + exts: PChar; + i: Integer; + found: Boolean; + extName: ShortString; +begin + result := false; + if length(name) = 0 then exit; + exts := glGetString(GL_EXTENSIONS); + if exts = nil then exit; + while (exts[0] <> #0) and (exts[0] = ' ') do Inc(exts); + while exts[0] <> #0 do + begin + if gwin_dump_extensions then + begin + i := 0; + while (exts[i] <> #0) and (exts[i] <> ' ') do Inc(i); + if i > 255 then + begin + e_WriteLog('FUUUUUUUUUUUUU', MSG_WARNING); + end + else + begin + Move(exts^, extName[1], i); + extName[0] := Char(i); + e_WriteLog(Format('EXT: %s', [extName]), MSG_NOTIFY); + end; + end; + found := true; + for i := 0 to length(name)-1 do + begin + if exts[i] = #0 then begin found := false; break; end; + if exts[i] <> name[i+1] then begin found := false; break; end; + end; + if found and ((exts[length(name)] = #0) or (exts[length(name)] = ' ')) then begin result := true; exit; end; + while (exts[0] <> #0) and (exts[0] <> ' ') do Inc(exts); + while (exts[0] <> #0) and (exts[0] = ' ') do Inc(exts); + end; +end; + function SDLMain(): Integer; +var + idx: Integer; + ltmp: Integer; begin {$IFDEF HEADLESS} e_NoGraphics := True; {$ENDIF} + e_WriteLog('Initializing OpenGL', MSG_NOTIFY); + InitOpenGL(gVSync); + e_WriteLog('Creating GL window', MSG_NOTIFY); if not CreateGLWindow(PChar(Format('Doom 2D: Forever %s', [GAME_VERSION]))) then begin @@ -638,11 +705,30 @@ begin exit; end; - e_WriteLog('Initializing OpenGL', MSG_NOTIFY); - InitOpenGL(gVSync); - {EnumDisplayModes();} + for idx := 1 to ParamCount do + begin + if ParamStr(idx) = '--opengl-dump-exts' then gwin_dump_extensions := true; + end; + + SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp); + e_WriteLog(Format('stencil buffer size: %d', [ltmp]), MSG_WARNING); + + gwin_has_stencil := (ltmp > 0); + + if not glHasExtension('GL_ARB_texture_non_power_of_two') then + begin + e_WriteLog('Driver DID''T advertised NPOT textures support', MSG_WARNING); + glLegacyNPOT := true; + end + else + begin + e_WriteLog('Driver advertised NPOT textures support', MSG_NOTIFY); + glLegacyNPOT := false; + end; + gwin_dump_extensions := false; + Init(); Time_Old := GetTimer();