summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 002448a)
raw | patch | inline | side by side (parent: 002448a)
author | FGSFDSFGS <derp.primus@gmail.com> | |
Wed, 6 Apr 2016 18:40:20 +0000 (21:40 +0300) | ||
committer | FGSFDSFGS <derp.primus@gmail.com> | |
Wed, 6 Apr 2016 18:42:40 +0000 (21:42 +0300) |
src/game/g_window.pas | patch | blob | history | |
src/lib/sdl2/sdl2.pas | patch | blob | history | |
src/lib/sdl2/sdlpixels.inc | patch | blob | history |
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index d4cd928673a591bd2b16dbf0d7156cf708cf2be9..a41c9f44b08ed50dae2524f5a3a1d9c554400233 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
end;
function g_Window_SetDisplay(PreserveGL: Boolean = False): Boolean;
+var
+ mode, cmode: TSDL_DisplayMode;
begin
Result := False;
e_WriteLog('Setting display mode...', MSG_NOTIFY);
- // if wWindowCreated and PreserveGL then
- // e_SaveGLContext(); // we need this and restore because of a bug in SDL1.2, apparently
-
wFlags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE;
if gFullscreen then wFlags := wFlags or SDL_WINDOW_FULLSCREEN;
if gWinMaximized then wFlags := wFlags or SDL_WINDOW_MAXIMIZED;
SDL_DestroyWindow(h_Wnd);
h_Wnd := nil;
end;
+
+ if gFullscreen then
+ begin
+ mode.w := gScreenWidth;
+ mode.h := gScreenHeight;
+ mode.format := 0;
+ mode.refresh_rate := 0;
+ mode.driverdata := nil;
+ if SDL_GetClosestDisplayMode(0, @mode, @cmode) = nil then
+ begin
+ gScreenWidth := 800;
+ gScreenHeight := 600;
+ end
+ else
+ begin
+ gScreenWidth := cmode.w;
+ gScreenHeight := cmode.h;
+ end;
+ end;
h_Wnd := SDL_CreateWindow(PChar(wTitle), gWinRealPosX, gWinRealPosY, gScreenWidth, gScreenHeight, wFlags);
if h_Wnd = nil then Exit;
SDL_GL_MakeCurrent(h_Wnd, h_GL);
SDL_ShowCursor(SDL_DISABLE);
- // if wWindowCreated and PreserveGL then
- // e_RestoreGLContext();
-
Result := True;
end;
function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SArray;
var
mode: TSDL_DisplayMode;
- res, i, k: Integer;
+ res, i, k, n, pw, ph: Integer;
begin
SetLength(Result, 0);
- k := 0;
- for i := 0 to SDL_GetNumDisplayModes(0) do
+ k := 0; SelRes := 0;
+ n := SDL_GetNumDisplayModes(0);
+ pw := 0; ph := 0;
+ for i := 0 to n do
begin
res := SDL_GetDisplayMode(0, i, @mode);
if res < 0 then continue;
+ if SDL_BITSPERPIXEL(mode.format) = gBPP then continue;
+ if (mode.w = pw) and (mode.h = ph) then continue;
if (mode.w = gScreenWidth) and (mode.h = gScreenHeight) then
SelRes := k;
Inc(k);
SetLength(Result, k);
Result[k-1] := IntToStr(mode.w) + 'x' + IntToStr(mode.h);
+ pw := mode.w; ph := mode.h
end;
e_WriteLog('SDL: Got ' + IntToStr(k) + ' resolutions.', MSG_NOTIFY);
diff --git a/src/lib/sdl2/sdl2.pas b/src/lib/sdl2/sdl2.pas
index 92f71d93376678ee60c0049ab7c6c0c794c9808a..4f1dfcaa0ac320d8801649d1d2331a6a67d9a867 100644 (file)
--- a/src/lib/sdl2/sdl2.pas
+++ b/src/lib/sdl2/sdl2.pas
//from "sdl_pixels.h"
-function SDL_PIXELFLAG(X: Cardinal): Boolean;
+function SDL_PIXELFLAG(X: Cardinal): Cardinal;
begin
- Result := (X shr 28) = $0F;
+ Result := (X shr 28) and $0F;
end;
-function SDL_PIXELTYPE(X: Cardinal): Boolean;
+function SDL_PIXELTYPE(X: Cardinal): Cardinal;
begin
- Result := (X shr 24) = $0F;
+ Result := (X shr 24) and $0F;
end;
-function SDL_PIXELORDER(X: Cardinal): Boolean;
+function SDL_PIXELORDER(X: Cardinal): Cardinal;
begin
- Result := (X shr 20) = $0F;
+ Result := (X shr 20) and $0F;
end;
-function SDL_PIXELLAYOUT(X: Cardinal): Boolean;
+function SDL_PIXELLAYOUT(X: Cardinal): Cardinal;
begin
- Result := (X shr 16) = $0F;
+ Result := (X shr 16) and $0F;
end;
-function SDL_BITSPERPIXEL(X: Cardinal): Boolean;
+function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
begin
- Result := (X shr 8) = $FF;
+ Result := (X shr 8) and $FF;
end;
function SDL_IsPixelFormat_FOURCC(format: Variant): Boolean;
index fc6aad39083ecd8f42427e248a52653df09803d2..d97f165ddc377c96649203384a443b6624751751 100644 (file)
((bits) << 8) | ((bytes) << 0))
}
-function SDL_PIXELFLAG(X: Cardinal): Boolean;
-function SDL_PIXELTYPE(X: Cardinal): Boolean;
-function SDL_PIXELORDER(X: Cardinal): Boolean;
-function SDL_PIXELLAYOUT(X: Cardinal): Boolean;
-function SDL_BITSPERPIXEL(X: Cardinal): Boolean;
+function SDL_PIXELFLAG(X: Cardinal): Cardinal;
+function SDL_PIXELTYPE(X: Cardinal): Cardinal;
+function SDL_PIXELORDER(X: Cardinal): Cardinal;
+function SDL_PIXELLAYOUT(X: Cardinal): Cardinal;
+function SDL_BITSPERPIXEL(X: Cardinal): Cardinal;
{
#define SDL_BYTESPERPIXEL(X) \
(SDL_ISPIXELFORMAT_FOURCC(X) ? \