Hey all,
I am trying to get all the available resolutions (w x h) using SDL_ListModes like it shows here:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_ListModes
but I am not sure how to translate that to Pascal...it seems to be a double pointer or something?
My code is crashing
Here is the code I have whipped up to try and enumerate the display settings:
Code:
type
TGraphicsMode = record
Width : Word;
Height : Word;
AspectRatio : Single;
IsWidescreen : Boolean;
end;
TGraphicsModeArray = array of TGraphicsMode;
procedure EnumerateDisplaySettings(var aGraphicsModes: TGraphicsModeArray; var aDesktopIsWideScreen: Boolean);
const
cNormalAspectRatio = 1024/768;
var
Index : Integer;
ScreenWidth : Integer;
ScreenHeight : Integer;
Modes : PPSDL_Rect;
begin
Modes := SDL_ListModes(nil,SDL_HWSURFACE);
if not Assigned(Modes^) then
Modes := SDL_ListModes(nil,SDL_SWSURFACE);
SetLength(aGraphicsModes,0);
Index := 0;
while Assigned(Modes^) do
begin
SetLength(aGraphicsModes,Index + 1);
aGraphicsModes[Index].Width := Modes^.w;
aGraphicsModes[Index].Height := Modes^.h;
aGraphicsModes[Index].AspectRatio := Modes^.w / Modes^.h;
aGraphicsModes[Index].IsWidescreen := Abs(aGraphicsModes[Index].AspectRatio - cNormalAspectRatio) > 0.1;
Inc(Index);
Inc(Modes^);
end;
end;
cheers,
Paul
Bookmarks