- Joined
- Jan 2, 2020
- Messages
- 1,414
I have problem with getting readpixels working on Mojo2. I dotn't read alot of memory so I know it is not the amount.
What follows first is the Mojo1 version and it works perfectly everywhere even on Android and with good speed.
Compare this with the Mojo2 version that locks up (On Android) and also the size of the square is half in size by some reason.
What am doing wrong with Mojo2?
Mojo1 version :
Mojo2 version :
What follows first is the Mojo1 version and it works perfectly everywhere even on Android and with good speed.
Compare this with the Mojo2 version that locks up (On Android) and also the size of the square is half in size by some reason.
What am doing wrong with Mojo2?
Mojo1 version :
Code:
Strict
Import mojo
'
Function Main:int()
New gamename()
Return 0
End
Class gamename Extends App
Field log:Image
Field x:Float =50
Field y:Float = 50
Field pix:Int[40*40]
Field img:Image
'
Method OnCreate:Int()
'
SetSwapInterval 1 ; SetUpdateRate 0
log = LoadImage("log.png")
img = CreateImage(40,40)
Return 0
End
Method OnRender:int()
Cls 0,0,250
DrawImage log,0,0
ReadPixels pix,MouseX(),MouseY(),40,40
img.WritePixels pix,0,0,40,40
DrawImage img,0,0
'
Return 0
End
End
Mojo2 version :
Code:
Strict
Import mojo2
Import brl.databuffer
Function Main:int()
New gamename()
Return 0
End
Class gamename Extends App
Field log:Image
Field x:Float =50
Field y:Float = 50
Field pix:DataBuffer = New DataBuffer(4 * 40 * 40)
Field img:Image
Field canvas:Canvas
Method OnCreate:Int()
canvas=New Canvas
SetSwapInterval 1 ; SetUpdateRate 0
log = Image.Load("log.png",0,0,0)
img = New Image(40,40)
Return 0
End
Method OnRender:int()
canvas.Clear 0,0,250
canvas.DrawImage log,0,0
canvas.ReadPixels MouseX(),MouseY(),40,40, pix
img.WritePixels 0,0,40,40,pix
canvas.DrawImage img,0,0
canvas.Flush
Return 0
End
End