16x9 Low Resolution Test

Advanced game related topics
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

16x9 Low Resolution Test

Post 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
Last edited by J. Baker on Wed Jul 28, 2010 9:25 pm, edited 7 times in total.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Thorium
Addict
Addict
Posts: 1308
Joined: Sat Aug 15, 2009 6:59 pm

Re: 16x9 Low Resolution Test

Post 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.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Thorium
Addict
Addict
Posts: 1308
Joined: Sat Aug 15, 2009 6:59 pm

Re: 16x9 Low Resolution Test

Post 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?
User avatar
Blue Steel
Enthusiast
Enthusiast
Posts: 132
Joined: Wed Aug 31, 2005 4:49 pm
Contact:

Re: 16x9 Low Resolution Test

Post 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
Currently using PureBasic 4.51(x86)

Image http://www.codingmonkeys.com
Covers many languages including PureBasic
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: 16x9 Low Resolution Test

Post by helpy »

Hello,

Two 5:4 monitors: 2x 1280x1024

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

cu, helpy
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: 16x9 Low Resolution Test

Post 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)

...
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: 16x9 Low Resolution Test

Post 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
Last edited by helpy on Wed Jul 28, 2010 6:21 pm, edited 2 times in total.
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post by J. Baker »

I think I got by this one line of code?

Code: Select all

KeepAspect = (((DesktopWidth(0) / 16) * 9) - DesktopHeight(0)) / 2
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: 16x9 Low Resolution Test

Post 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
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post 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. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: 16x9 Low Resolution Test

Post 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
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 16x9 Low Resolution Test

Post by J. Baker »

Sorry, my mistake. Just had to make a minor change.

Code: Select all

KeepAspect = (DesktopHeight(0) - (DesktopWidth(0)  / 16) * 9) / 2
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply