Strict
Import mojo2
' Set the parameters for a GLFW window, to make it resize visually.
#GLFW_WINDOW_WIDTH = 800
#GLFW_WINDOW_HEIGHT = 400
#GLFW_WINDOW_RESIZABLE = True
#GLFW_WINDOW_RENDER_WHILE_RESIZING = True
'Set the Android screen to landscape and let the user choose orientation for that.
#ANDROID_SCREEN_ORIENTATION="sensorLandscape"
' The size of our virtual window. This is the resolution you work with while rendering.
Const VWIDTH:Int = 320
Const VHEIGHT:Int = 240
Global viewW:Int = 200
Global viewH:Int = 100
Class MyApp Extends App
Field myCanvas:Canvas
Method OnCreate:Int()
myCanvas = New Canvas()
viewW = DeviceWidth()
viewH = DeviceHeight()
Return 0
End
Method OnUpdate:Int()
If KeyHit(KEY_UP)
viewW += 10
viewH += 10
Print(viewW + " " + viewH)
Endif
If KeyHit(KEY_DOWN)
viewW -= 10
viewH -= 10
Print(viewW + " " + viewH)
Endif
If KeyHit(KEY_SPACE)
viewW = DeviceWidth()
viewH = DeviceHeight()
Endif
Return 0
End
Method OnRender:Int()
myCanvas.SetViewport(0, 0, viewW, viewH)
myCanvas.SetProjection2d(0, VWIDTH, 0, VHEIGHT)
'Here goes your drawing routine:
myCanvas.Clear($c96d36)
myCanvas.DrawText(VWIDTH + "x"+ VHEIGHT + " on " + viewW + "x" + viewH, VWIDTH/2, VHEIGHT/2, 0.5, 0.5)
myCanvas.Flush()
Return 0
End
End
Function Main:Int()
New MyApp
Return 0
End
#HTML5_CANVAS_WIDTH=1920 'Set the width of the canvas.
#HTML5_CANVAS_HEIGHT=1080 'Set the height of the canvas.
SetProjection2d(0,1919,0,1079)
Field cw: Int = 300
Field ch: Int = 150
Field canvas:Canvas
Const WIDTH:Int = 1024
Const HEIGHT:Int =768
Method OnCreate:Int()
'Set the update rate to 60 frames per second
SetUpdateRate(60)
canvas = New Canvas
cw = DeviceWidth()
ch = DeviceHeight()
canvas.SetViewport(0, 0, cw, ch)
canvas.SetProjection2d(0, WIDTH, 0, HEIGHT)
img = New Image(cw, ch)
img.SetHandle(0.0, 0.0)
dp = New DataBuffer(cw * ch * 4)
'Pyro set up
letterBox = prCalcLetterbox(WIDTH, HEIGHT,[0, 0, DeviceWidth(), DeviceHeight()])
guiLayer=New prGuiLayer()
guiLayer.SetProjection WIDTH,HEIGHT
guiLayer.SetAmbientLight 1,1,1,1
guiLayer.Renderer.SetClearMode 0
guiLayer.SetViewport letterBox[0],letterBox[1],letterBox[2],letterBox[3]
End
Method OnRender:Int()
letterBox = prCalcLetterbox(WIDTH, HEIGHT,[0, 0, DeviceWidth(), DeviceHeight()])
guiLayer.SetViewport letterBox[0], letterBox[1], letterBox[2], letterBox[3]
guiLayer.SetOverlay canvas
canvas.Clear
draw()
canvas.Flush()
guiLayer.Render
Return 0
End
Strict
#HTML5_CANVAS_WIDTH=1024 'Set the width of the canvas.
#HTML5_CANVAS_HEIGHT=768 'Set the height of the canvas.
Import mojo2
DeviceWidth()
DeviceHeight()
IF you added these after a first build, they don't get processed. You have to delete the build folder to have changed settings to be effective.For some reason it is not working, when I print the