Camera viewport seems to be always 640 x 480 here:
#Import "<std>"
#Import "<mojo3d>"
Using std..
Using mojo..
Using mojo3d..
' ----------------------------------------
' Application name...
' ----------------------------------------
Global AppName:String = "My 3D Game"
Class Game Extends Window
Const SHIFT_BOOST:Float = 5.0
Field camera_boost:Float = 1.0
' Basic 3D scene requirements...
Field scene:Scene
Field camera:Camera
Field light:Light
' Test cube...
Field cube:Model
Method New (title:String, width:Int, height:Int, flags:WindowFlags)
Super.New (title, width, height, flags)
scene = Scene.GetCurrent () ' Important!
camera = New Camera
' Camera settings...
camera.Near = 0.1
' Camera position...
camera.Move (0, 0, -2)
'camera.Viewport = Window.Rect
light = New Light
light.Move (-10, 10, -10)
cube = New Model (Mesh.CreateBox (New Boxf (-0.5, -0.5, -0.5, 0.5, 0.5, 0.5)), New PbrMaterial (Color.Aluminum))
cube.Rotate (0, 45, 0)
End
Method UpdateGame:Void ()
End
Method OnRender (canvas:Canvas) Override
ProcessInput ()
UpdateGame ()
cube.Rotate (0.0, 1.0, 0.0)
' Tell app to draw frame when ready...
RequestRender ()
' Render scene to canvas (passed to OnRender by mojo), from camera...
scene.Render (canvas)
canvas.DrawText ("VP:" + camera.Viewport, 20, 20)
End
Method ProcessInput:Void ()
If Keyboard.KeyHit (Key.Space) Then light.CastsShadow = Not light.CastsShadow
If Keyboard.KeyDown (Key.LeftShift)
camera_boost = SHIFT_BOOST
Else
camera_boost = 1.0
Endif
If Keyboard.KeyHit (Key.Escape) Then App.Terminate ()
If Keyboard.KeyDown (Key.A)
camera.Move (0.0, 0.0, 0.1 * camera_boost)
Endif
If Keyboard.KeyDown (Key.Z)
camera.Move (0.0, 0.0, -0.1 * camera_boost)
Endif
If Keyboard.KeyDown (Key.Left)
camera.Rotate (0.0, 1.0, 0.0)
Endif
If Keyboard.KeyDown (Key.Right)
camera.Rotate (0.0, -1.0, 0.0)
Endif
If Keyboard.KeyDown (Key.Up)
camera.Rotate (1.0, 0.0, 0.0, True)
Endif
If Keyboard.KeyDown (Key.Down)
camera.Rotate (-1.0, 0.0, 0.0, true)
Endif
End
End
Function Main ()
' Windowed mode...
' Local width:Int = 640
' Local height:Int = 480
' Local flags:WindowFlags = WindowFlags.Center
' Full-screen mode (comment out above)...
Local width:Int = 1024
Local height:Int = 768
Local flags:WindowFlags = WindowFlags.Center'Fullscreen
New AppInstance
New Game (AppName, width, height, flags)
App.Run ()
End
Calling camera.Viewport = Window.Rect (commented out above) fixes it.
Original Author: DruggedBunny
Camera viewport seems to be always 640 x 480 here:
Calling
camera.Viewport = Window.Rect
(commented out above) fixes it.