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
|