What the hell....

Monkey Targets Forums/Desktop/What the hell....

bruZard(Posted 2011) [#1]
I've a strange problem: all bananas runs fine with target "glfw", just my own minimal try does not.
'Strict

Import mojo

Function Main()
	New myGame
End Function


Class myGame Extends App
	Field screen:Image
	
	Method OnCreate()
		screen = LoadImage("screen.png")
		SetUpdateRate(30)
	End
	
	Method OnUpdate()
	End
	
	Method OnRender()
		PushMatrix()
		DrawImage(screen, 0, 0)
		PopMatrix()
	End
End Class

all other targets works fine, just glfw not. Any idea whats going wrong?


bruZard(Posted 2011) [#2]
ok ... now it works, but: get GLFW other scale values on DrawImage()?


DruggedBunny(Posted 2011) [#3]
What's happening for you? I've just tried your code with a local PNG image, and both HTML5 and GLFW look exactly the same for me.


bruZard(Posted 2011) [#4]
dont know whats going wrong, now (without changes), it works :|


bruZard(Posted 2011) [#5]
ok, it will not work with GLFW:
Import mojo

Class Test Extends App
	Field mX:Int
	Field mY:Int
	Field w:Float
	Field h:Float
	Field rot:Float
	Field fps:Int
	Field tmpFps:Int 
	Field time:Int
	
	Field dx:Float
	Field dy:Float
	Field ix:Float
	Field iy:Float
	
	Field screen:Image
	Field monkey:Image
	
	Field bName:String
	
	Method OnCreate:Int()
		screen = LoadImage("screen.jpg")
		monkey = LoadImage("monkey.png")
		mX = 0.0
		mY = 0.0
		rot = 0.0
		time = Millisecs()
		
		dx = 1.0
		dy = 1.0
		ix = 0.0
		iy = 0.0
		
		SetUpdateRate(900)
		
		Return 0
	End
	
	Method OnUpdate:Int()		
		Local cw:Float = DeviceWidth()
		Local ch:Float = DeviceHeight()
		If cw <> w Or ch <> h
			w = cw
			h = ch
			If cw > ch Then rot = 0.0 Else rot = 0.5
		Endif
		
		mX = MouseX()
		mY = MouseY()
			
		ix = ix + dx
		iy = iy + dy
		
		If ix + monkey.Width() > w 
			dx = -1
		Endif
		
		If iy + monkey.Height() > h
			dy = -1
		Endif
		
		If ix < 0
			dx = 1
		Endif
		
		If iy < 0 
			dy = 1
		Endif
				
		tmpFps = tmpFps + 1
		Local tmpTime:Int = Millisecs()
		If tmpTime - time > 1000
			fps = tmpFps
			tmpFps = 0
			time = tmpTime
		Endif
		Return 0
	End
	
	Method changeDirection:Float(dir:Float)
		Return 0 - dir 
	End
	
	Method OnRender:Int()
		DrawImage(screen, 0, 0, 0.0, w / screen.Width(), h / screen.Height())
		DrawImage(monkey, ix, iy)
		DrawText(mX + ", " + mY + " @" + w + "x" + h + " : " + fps + "FPS on " + bName, 10, 10)
		Return 0
	End
	
	Method MidHandle:Void(image:Image)
		image.SetHandle( Floor(image.Width() * 0.5), Floor(image.Height() * 0.5) )
	End
End


Function Main:Int()
	New Test
	Return 0
End



bruZard(Posted 2011) [#6]
Found it: the width and height of the display must be a float.


bruZard(Posted 2011) [#7]
ok ... that wasnt the point .. no idea ...


bruZard(Posted 2011) [#8]
i've just get a PNG fpr "screen" and now it works ... crazy