Widescreen Aspect ratio and more

BlitzMax Forums/BlitzMax Programming/Widescreen Aspect ratio and more

Robert Cummings(Posted 2006) [#1]
I'm interested in supporting widescreen on my game, but I want to make windowed mode proper widescreen aspect ratio, but I want fullscreen under 4:3 to have little borders at the top and bottom.

This means it's a widescreen-native game, and feels kinda cinematic.

What do I need to do in order to support both? All wisdom accepted and gratefully appreciated :)


TartanTangerine (was Indiepath)(Posted 2006) [#2]
COuple of things

1) Tweak the matrix so you don't need to arse around with re-calculating stuff. It's undocumented in my module but you can also select the position and scale of the projection.
2) Use a *REAL* viewport (BMAX Viewports are 4 clip-planes and not a true viewport)

Here is the cross-platform Viewport code lifted straight out of my Render 2 Texture Mod.

	Function ViewportSet(X:Int=0,Y:Int=0,Width:Int=640,Height:Int=480,FlipY:Byte=False)
	?Win32
		If DX
			TD3D7Max2DDriver(_max2dDriver).viewport.dwX=x
			TD3D7Max2DDriver(_max2dDriver).viewport.dwY=y
			TD3D7Max2DDriver(_max2dDriver).viewport.dwWidth=width
			TD3D7Max2DDriver(_max2dDriver).viewport.dwHeight=height
			PrimaryDevice.device.SetViewport(TD3D7Max2DDriver(_max2dDriver).viewport)
		Else
	?
			If FlipY
				glViewport(X, Y, Width, Height)
				glMatrixMode(GL_PROJECTION)
				glPushMatrix()
				glLoadIdentity()
				gluOrtho2D(X, GraphicsWidth(), GraphicsHeight(),Y)
				glScalef(1, -1, 1)
				glTranslatef(0, -GraphicsHeight(), 0)
				glMatrixMode(GL_MODELVIEW)
			Else
				glViewport(X, Y, Width, Height)
				glMatrixMode(GL_PROJECTION)
				glLoadIdentity()
				glOrtho(X, GraphicsWidth(), GraphicsHeight(), Y, -1, 1)
				glMatrixMode(GL_MODELVIEW)
				glLoadIdentity()
			EndIf
	?Win32
		EndIf
	?
	'	Print "tRender : ViewportSet OK"
		Return True
	EndFunction



Robert Cummings(Posted 2006) [#3]
Interesting - and thanks! will you be selling these soon?


TartanTangerine (was Indiepath)(Posted 2006) [#4]
Yeah :) It's been a busy bank holiday so I'll be back at work tomorrow earning my keep :D