ok, here is my code now - it isn't crashing anymore, but it always seems to reach this line and then exit as that condition is true:
Code:
// all modes are available
if ppmode = PPSDL_Rect( -1 ) then Exit;
I was hoping to get an actual list of available video resolutions, but this doesn't seem to happen
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;
VideoInfo : PSDL_VideoInfo;
ppmode : PPSDL_Rect;
begin
SetLength(aGraphicsModes,0);
VideoInfo := SDL_GetVideoInfo;
ppmode := SDL_ListModes(VideoInfo^.vfmt,SDL_OPENGL or SDL_HWSURFACE);
// no hardware modes found
if ppmode = PPSDL_Rect( 0 ) then
ppmode := SDL_ListModes(VideoInfo^.vfmt,SDL_OPENGL or SDL_SWSURFACE);
// no software modes found
if ppmode = PPSDL_Rect( 0 ) then Exit;
// all modes are available
if ppmode = PPSDL_Rect( -1 ) then Exit;
// return available modes
Index := 0;
while Assigned(ppmode^) do
begin
SetLength(aGraphicsModes,Index + 1);
aGraphicsModes[Index].Width := ppmode^^.w;
aGraphicsModes[Index].Height := ppmode^.h;
aGraphicsModes[Index].AspectRatio := ppmode^.w / ppmode^.h;
aGraphicsModes[Index].IsWidescreen := Abs(aGraphicsModes[Index].AspectRatio - cNormalAspectRatio) > 0.1;
Inc(Index);
Inc(ppmode^);
end;
end;
Any ideas?
If I can't do it this way using SDL, I do have a windows only way already, but then I would need a Linux/Mac OS X way too...
cheers,
Paul
Bookmarks