Code: Select all
;scales a low resolution 16x9 screen to a monitor of any aspect ratio
;July 28 2010
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Sprite system can't be initialized", 0)
End
EndIf
ExamineDesktops()
KeepAspect = (DesktopHeight(0) - (DesktopWidth(0) / 16) * 9) / 2 ;this line does it all mathematically
If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "16x9 Low Resolution Test", #PB_Window_BorderLess)
SetWindowColor(0, RGB(0, 0, 0))
If OpenWindowedScreen(WindowID(0), 0, KeepAspect, 640, 360, 1, 0, KeepAspect)
CreateSprite(0, 640, 360)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 640, 360, RGB(255, 255, 255))
Box(32, 32, 256, 256, RGB(0, 0, 255))
Box(256, 256, 64, 64, RGB(255, 0, 0))
Box(384, 128, 512, 512, RGB(0, 255, 0))
StopDrawing()
EndIf
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
Repeat
ExamineKeyboard()
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End
EndIf
Until Event = 0
SetFrameRate(30)
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(0, 0, 0)
ForEver