I'm not sure if you got ProjMatrix.mod to work, so here's the full Virtual Graphics Type...
Strict
Type TVirtualGraphics
Global virtualWidth, virtualHeight
Global xRatio!, yRatio!
Function Set(width=640, height=480)
TVirtualGraphics.virtualWidth = width
TVirtualGraphics.virtualHeight = height
TVirtualGraphics.xRatio! = width / Double(GraphicsWidth())
TVirtualGraphics.yRatio! = height / Double(GraphicsHeight())
?Win32
Local D3D7Driver:TD3D7Max2DDriver = TD3D7Max2DDriver(_max2dDriver)
If D3D7Driver
Local matrix#[] = [2.0 / width, 0.0, 0.0, 0.0,..
0.0, -2.0 / height, 0.0, 0.0,..
0.0, 0.0, 1.0, 0.0,..
-1 - (1.0 / width), 1 + (1.0 / height), 1.0, 1.0]
D3D7Driver.device.SetTransform(D3DTS_PROJECTION, matrix)
Else
?
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glortho(0, width, height, 0, -1, 1)
glMatrixMode(GL_MODELVIEW)
?Win32
EndIf
?
End Function
Function MouseX()
Return (BRL.PolledInput.MouseX() * TVirtualGraphics.xRatio!)
End Function
Function MouseY()
Return (BRL.PolledInput.MouseY() * TVirtualGraphics.yRatio!)
End Function
End Type
'----------------------------------------------- TEST -----------------------------------------------
'SetGraphicsDriver GLMax2DDriver()
SeedRnd MilliSecs()
Local index = Rand(0, CountGraphicsModes() - 1)
Local screenW, screenH, screenD, screenR
GetGraphicsMode(index, screenW, screenH, screenD, screenR)
Graphics screenW, screenH, screenD
TVirtualGraphics.Set(1024, 768)
HideMouse
AutoMidHandle True
Local image:TImage = LoadImage(getenv_("BMXPATH") + "/doc/bmax120.png")
Assert image Else "Oi..."
Local x = Rand(0, TVirtualGraphics.virtualWidth - 1)
Local y = Rand(0, TVirtualGraphics.virtualheight - 1)
Local xInc = Rand(1, 4)
Local yInc = Rand(1, 4)
Local scale#
SetClsColor 0, 0, 100
Repeat
x :+ xInc
If x >= TVirtualGraphics.virtualWidth
x = TVirtualGraphics.virtualWidth - 1
xInc = -xInc
ElseIf x < 0
x = 0
xInc = -xInc
EndIf
y :+ yInc
If y >= TVirtualGraphics.virtualHeight
y = TVirtualGraphics.virtualHeight - 1
yInc = -yInc
ElseIf y < 0
y = 0
yInc = -yInc
EndIf
scale# = 1 + (Cos(MilliSecs() / 10.0) * 0.5)
Cls
SetTransform(Sin(MilliSecs() / 40.0) * 180.0, scale#, scale#)
DrawImage image, x, y
SetTransform(0, TVirtualGraphics.xRatio!, TVirtualGraphics.xRatio!)
DrawText screenW + " x " + screenH + " x " + screenD, 12, 12
Plot TVirtualGraphics.MouseX(), TVirtualGraphics.MouseY()
Flip
Until KeyHit(KEY_ESCAPE)
EndHere's a textured poly function, if you need it (I think there are a couple of these in the code archives too)...
Strict
'SetGraphicsDriver GLMax2DDriver()
Graphics 800, 600, 0
Local img:TImage = LoadImage(getenv_("BMXPATH") + "\doc\bmax120.png")
Assert img Else "Oi...Where's me data gone?"
SetOrigin(400, 300)
SetHandle(50, 50)
SetBlend ALPHABLEND
'SetColor 0, 0, 255
Repeat
Cls
Local xo# = Cos(MilliSecs() / 10#) * 10, yo# = Sin(MilliSecs() / 10#) * 10
Local ts# = 1 + (Cos(MilliSecs() / 100#) * 0.5)
SetTransform(MilliSecs() / 100#, ts#, ts#)
SetAlpha 1
DrawTexturedPoly([0 - xo#, 0 - yo#, 0.0, 0.0, 100 + xo#, 0 + yo#, 1.0, 0.0,..
100 + xo#, 100 + yo#, 1.0, 1.0, 0 - xo#, 100 - yo#, 0.0, 1.0], img)
SetAlpha 0.5 + (Cos(MilliSecs() / 50#) * 0.5)
DrawPoly([0.0, 0.0, 100.0, 0.0, 100.0, 100.0, 0.0, 100.0])
Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()
End
Function DrawTexturedPoly(xyuv#[], image:TImage, frame=0, fan=1)
Local textureWidthRatio! = Double(image.width) / Pow2Size(image.width)
Local textureHeightRatio! = Double(image.height) / Pow2Size(image.height)
Local hx#, hy#, ox#, oy#
GetHandle(hx#, hy#)
GetOrigin(ox#, oy#)
?Win32
Local DXDriver:TD3D7Max2DDriver = TD3D7Max2DDriver(_max2dDriver)
If DXDriver
'DX
Local verts#[(xyuv#.length / 4) * 6]
Local vCount
For Local c=0 Until xyuv#.length Step 4
verts#[vCount] = ((xyuv#[c] - hx#) * DXDriver.ix#) + ((xyuv#[c + 1] - hy#) * DXDriver.iy#) + ox#
verts#[vCount + 1] = ((xyuv#[c] - hx#) * DXDriver.jx#) + ((xyuv#[c + 1] - hy#) * DXDriver.jy#) + oy#
verts#[vCount + 2] = 0
(Int Ptr(Float Ptr(verts#)))[vCount + 3] = DXDriver.drawcolor
verts#[vCount + 4] = xyuv#[c + 2] * textureWidthRatio!
verts#[vCount + 5] = xyuv#[c + 3] * textureHeightRatio!
vCount :+ 6
Next
DXDriver.SetActiveFrame(TD3D7ImageFrame(image.Frame(frame)))
If fan
DXDriver.device.DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, verts#, xyuv#.length / 4, 0)
Else
DXDriver.device.DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, verts#, xyuv#.length / 4, 0)
EndIf
Else
?
'GL
'Can't get at GLMax2D's transform info, so...
Local sx#, sy#
GetScale(sx#, sy#)
glPushMatrix()
glBindTexture(GL_TEXTURE_2D, TGLImageFrame(image.Frame(frame)).name)
glEnable(GL_TEXTURE_2D)
glTranslatef(ox#, oy#, 0.0)
glRotatef(GetRotation(), 0.0, 0.0, 1.0)
glScalef(sx#, sy#, 1.0)
If fan Then glBegin(GL_POLYGON) Else glBegin(GL_TRIANGLE_STRIP)
For Local c=0 Until xyuv#.length Step 4
glTexCoord2f(xyuv#[c + 2] * textureWidthRatio!, xyuv#[c + 3] * textureHeightRatio!)
glVertex2f(xyuv#[c] - hx#, xyuv#[c + 1] - hy#)
Next
glEnd
glDisable(GL_TEXTURE_2D)
glPopMatrix()
?Win32
EndIf
?
End Function
Function Pow2Size(n)
Local t = 1
While t < n
t :* 2
Wend
Return t
End Function