Page 1 of 2

16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 7:35 am
by J. Baker
I started working on an idea for a 2D game a while back and I'm now testing out some code. This is a resolution test to see if I could make a 640x360 resolution scale on any monitor. And also keep the aspect ratio. If you have a 16x10 or 4x3 monitor, could you test and report back? I just want to make sure all is fine. Thanks!

EDIT: updated code

Code: Select all

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

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

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 9:17 am
by Thorium
Just white screen, so it's impossible to tell if dimensions of sprites are correct. You have to display something to see if it's streched.

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 9:27 am
by J. Baker
Thorium wrote:Just white screen, so it's impossible to tell if dimensions of sprites are correct. You have to display something to see if it's streched.
Well I do have graphics here that I tested. But my monitor is 16x9. And it did scale them properly. I just need to know if the aspect ratio looked right for 4x3 and 16x10.

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 9:30 am
by Thorium
J. Baker wrote:
Thorium wrote:Just white screen, so it's impossible to tell if dimensions of sprites are correct. You have to display something to see if it's streched.
Well I do have graphics here that I tested. But my monitor is 16x9. And it did scale them properly. I just need to know if the aspect ratio looked right for 4x3 and 16x10.
Don't know, the whole screen is white on my 4x3. Is this what you want?

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 2:27 pm
by Blue Steel
on my non wide screen monitor i see at the top a grey bar then below it a white box and then below that a grey bar again..

ie: similar to when i'm watching a wide screen movie onm my non wide screen monitor

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 3:09 pm
by helpy
Hello,

Two 5:4 monitors: 2x 1280x1024

Result: The whole screen of the first monitor is white!

cu, helpy

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 3:28 pm
by helpy
Try this:

Code: Select all

;...

If DesktopHeight(0) = (DesktopWidth(0) * 9) / 16 ;16x9 ratio
	KeepAspectX = 0
	KeepAspectY = 0
ElseIf DesktopHeight(0) > (DesktopWidth(0) * 9) / 16
	KeepAspectX = 0
	KeepAspectY = (DesktopHeight(0) - DesktopWidth(0)*9/16) / 2
Else ;    :-)    Does such an ration exist ???          :-)
	KeepAspectX = (DesktopWidth(0) - DesktopHeight(0)*16/9) / 2
	KeepAspectY = 0
EndIf

If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "16x9 Low Resolution Test", #PB_Window_BorderLess)
	
	If OpenWindowedScreen(WindowID(0), KeepAspectX, KeepAspectY, 640, 360, 1, KeepAspectX, KeepAspectY)

...

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 5:27 pm
by J. Baker
@Thorium, what resolution were you using?

@Blue Steel, thanks!
helpy wrote:Hello,

Two 5:4 monitors: 2x 1280x1024

Result: The whole screen of the first monitor is white!

cu, helpy
Looks like I'll have to add more aspect ratios.

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 5:47 pm
by helpy
J. Baker wrote:Looks like I'll have to add more aspect ratios.
Why? Calculate it:

Code: Select all

If InitSprite() = 0 Or InitKeyboard() = 0
	MessageRequester("Error", "Sprite system can't be initialized", 0)
	End
EndIf

ExamineDesktops()

RatioX = 16
RatioY =  9

If DesktopHeight(0) = DesktopWidth(0) * RatioY / RatioX
	KeepAspectX = 0
	KeepAspectY = 0
ElseIf DesktopHeight(0) > (DesktopWidth(0) * RatioY) / RatioX
	KeepAspectX = 0
	KeepAspectY = (DesktopHeight(0) - DesktopWidth(0) * RatioY / RatioX) / 2
Else ;    :-)    Does such an ratio exist ???          :-)        would be an very wide screen
	KeepAspectX = (DesktopWidth(0) - DesktopHeight(0) * RatioX / RatioY) / 2
	KeepAspectY = 0
EndIf

If OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), Str(RatioX) + "x" + Str(RatioY) + " Low Resolution Test", #PB_Window_BorderLess)
	
	If OpenWindowedScreen(WindowID(0), KeepAspectX, KeepAspectY, 640, 360, 1, KeepAspectX, KeepAspectY)       
		CreateSprite(0, 640, 360)
		If StartDrawing(SpriteOutput(0))
			Box(0, 0, 640, 360, RGB(255, 255, 255))
			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

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 5:59 pm
by J. Baker
KeepAspectY = (DesktopHeight(0) - DesktopWidth(0) * RatioY / RatioX) / 2

Doesn't seem correct when I calculate a 1280x1024 resolution. It gives 72 when it should be more like 152.

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 6:09 pm
by J. Baker
I think I got by this one line of code?

Code: Select all

KeepAspect = (((DesktopWidth(0) / 16) * 9) - DesktopHeight(0)) / 2

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 6:19 pm
by helpy

Code: Select all

KeepAspectY = (DesktopHeight(0) - DesktopWidth(0) * RatioY / RatioX) / 2
KeepAspectY = (1024 - 1280 * 9 / 16) / 2
KeepAspectY = (1024 - 720) / 2
KeepAspectY = 304 / 2
KeepAspectY = 152

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 6:25 pm
by J. Baker
Thanks helpy but I think I got with the one line of code two post up. I also updated the first post with it. ;)

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 6:44 pm
by helpy
But it does not work on my PC!

Code: Select all

KeepAspect = (((DesktopWidth(0) / 16) * 9) - DesktopHeight(0)) / 2
KeepAspect = (((1280 / 16) * 9) - 1024) / 2
KeepAspect = ((80 * 9) - 1024) / 2
KeepAspect = ((720 - 1024) / 2
KeepAspect = -152
NEGATIVE Result!

Image

Re: 16x9 Low Resolution Test

Posted: Wed Jul 28, 2010 6:54 pm
by J. Baker
Sorry, my mistake. Just had to make a minor change.

Code: Select all

KeepAspect = (DesktopHeight(0) - (DesktopWidth(0)  / 16) * 9) / 2