smarthaert / phoenixlib

Automatically exported from code.google.com/p/phoenixlib
0 stars 0 forks source link

Please add Device.Display.GetOptimalResolution #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This must return the next avaliable resolution that keeps the current desktop 
aspectratio and that is >= the AGameResolution;

Here is a BAD example of how to implement this! =)

function TGame.GetOptimalResolution(AGameResolution: TSizei): TSizei;
var
  AspectRatio: Single;
  DestopMode: TPHXDisplayMode;

  TempDisplayMode: TPHXDisplayMode;
  Index: Integer;
begin
  // This must return the next avaliable resolution that keeps the current desktop aspectratio
  // and that is >= the AGameResolution;

  DestopMode := Device.Display.DesktopMode;
  AspectRatio := DestopMode.Width / DestopMode.Height;

  Result := SizeI(DestopMode.Width, DestopMode.Height);

  for Index := 0 to Device.Display.Count do
    begin
      TempDisplayMode := Device.Display.List[Index];

      if SameValue(AspectRatio, TempDisplayMode.Width / TempDisplayMode.Height, 0.01) then
        begin
          if (TempDisplayMode.Width < Result.Width) or (TempDisplayMode.Height < Result.Height) then
            if (TempDisplayMode.Width >= AGameResolution.Width) and (TempDisplayMode.Height >= AGameResolution.Height) then
              Result := SizeI(TempDisplayMode.Width, TempDisplayMode.Height);
        end;
    end;

end;

Original issue reported on code.google.com by wagenhei...@gmail.com on 11 Nov 2010 at 12:18

GoogleCodeExporter commented 9 years ago
And How do you suggest to correct the mouse position when using diferents 
VirtualViewPort? 

Original comment by wagenhei...@gmail.com on 11 Nov 2010 at 12:32

GoogleCodeExporter commented 9 years ago

Original comment by andreas....@gmail.com on 11 Nov 2010 at 8:33