• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Bug?

RaspberryDJ

New member
Joined
Jun 3, 2019
Messages
122
I tried this example in MacOS Desktop, and I saw these black squares around the arrows?
HTML works as it should. I haven't had opportunity to try other platforms yet.
Maybe someone could try this on Windows Desktop and see if they get the same black squares?

624


Cerberus:
Import mojo2

Global blockw:Int=32
Global blockh:Int=32

Class block
    Field x:Int
    Field y:Int   
    Field tx:Int
    Field ty:Int
    Field movedown:Bool=False
    Method New(x:Int,y:Int)
        Self.x = x
        Self.y = y
    End Method
End Class

Class machine
    Field map:Bool[][]
    Field mapwidth:Int
    Field mapheight:Int
    Field myblock:List<block> = New List<block>
    Method New(mapwidth:Int,mapheight:Int)   
        Self.mapwidth = mapwidth
        Self.mapheight = mapheight
        map = New Bool[mapwidth][]
        For Local i=0 Until mapwidth
            map[i] = New Bool[mapheight]
        Next
        For Local i=0 Until 50
            Local x:Int=Rnd(0,mapwidth)
            Local y:Int=Rnd(0,mapheight)
            createblock(x,y)
        Next
    End Method
    
    Method update()
        addblocks()
        destroyblocks()
        For Local i1:=Eachin myblock
            i1.movedown = False
            If i1.y+1 < mapheight Then
                i1.movedown = True
                If map[i1.x][i1.y+1] = True Then i1.movedown = False
            End If
        Next
        For Local i1:=Eachin myblock
            If i1.movedown = True
                map[i1.x][i1.y] = False
                map[i1.x][i1.y+1] = True
                i1.y += 1   
            End If
        Next
    End Method
    
    Method destroyblocks()
        Local ch:Int=(GetDate[5]*10)+5       
        For Local i:=Eachin myblock
            If Rnd(0,ch)<2
                map[i.x][i.y] = False
                myblock.Remove(i)
            End If
        Next
    End Method
    
    Method addblocks()
        Local gw:Int[mapwidth]
        For Local i:=Eachin myblock
            gw[i.x]+=1
        Next
        For Local i=0 Until mapwidth
            If Rnd(0,100)<3
                If gw[i] < mapheight/1.2
                    createblock(i,0)
                End If
            End If
        Next
    End Method
    
    Method createblock(x:Int,y:Int)
        If map[x][y] = True Then Return
        map[x][y] = true
        myblock.AddLast(New block(x,y))
    End Method
    
    Method blockexists:Bool(x:Int,y:Int)
        For Local i:=Eachin myblock
            If i.x = x And i.y = y Then Return True
        Next
        Return False
    End Method
    
    Method draw(imagecanvas:Canvas)
        'DebugLog 15.0/10.0
        Local cy:Float = 1.0/15.0
        For Local i:=Eachin myblock
            Local a:Float = cy*i.y
            imagecanvas.SetColor(a,a,0)
            imagecanvas.DrawRect(i.x*blockw,i.y*blockh,blockw,blockh)
        Next
    End Method
    
End Class

Class grid
    Field image:Image
    Field imagecanvas:Canvas
    Field gridw:Int
    Field gridh:Int
    Field cellw:Int
    Field cellh:Int
    
    Method New(width:Int,height:Int,cellw:Int,cellh:Int)
        Self.gridw = width
        Self.gridh = height
        Self.cellw = cellw
        Self.cellh = cellh
        image = New Image(width,height)
        image.SetHandle(0,0)
        imagecanvas = New Canvas(image)
        createimage()       
    End Method
    
    Method createimage()
        Local x:Int=0
        Local y:Int=0
        Local exitloop:Bool=False
        'imagecanvas.SetColor(1,1,1)
        Local cy:Float=1.0/gridh
        While exitloop = False
            imagecanvas.SetColor(1-cy*y,0,0)
            imagecanvas.DrawLine(x,y,x+cellw,y)
            imagecanvas.DrawLine(x,y,x,y+cellh)
            x+=cellw
            If x>gridw Then
                x=0
                y+=cellh
            End If
            If y>gridh Then exitloop = True
        Wend
        imagecanvas.Flush()
    End Method
End Class

Class arrow
    Field image:Image
    Field imagecanvas:Canvas
    Method New(width:Int,height:Int)
        image = New Image(width,height)
        imagecanvas = New Canvas(image)
        createimage()
    End Method
    
    Method createimage()
        imagecanvas.SetColor 1,1,1
        Local w:Float=image.Width()
        Local h:Float=image.Height()
        Local pol:Float[14]
        pol[0] = 0
        pol[1] = h/2       
        pol[2] = w/3
        pol[3] = h       
        pol[4] = w/3
        pol[5] = h/1.5       
        pol[6] = w
        pol[7] = h/1.5       
        pol[8] = w
        pol[9] = h/3       
        pol[10] = w/3
        pol[11] = 0+h/3       
        pol[12] = w/3
        pol[13] = 0
        imagecanvas.DrawPoly(pol)
        imagecanvas.Flush
    End Method
End Class

Global myarrow:arrow
Global mygrid:grid
Global mymachine:machine

Class MyApp Extends App
    Field canvas:Canvas
    Field angle:Int=0
    
    Method OnCreate()
        SetUpdateRate(60)
        myarrow = New arrow(100,50)
        mygrid = New grid(DeviceWidth(),DeviceHeight(),32,32)
        mymachine = New machine(32,15)
        canvas=New Canvas
    End Method
    
    Method OnUpdate()
        angle+=1
        If angle>359 Then angle = 0
        mymachine.update
    End Method
    
    Method OnRender()
        canvas.Clear 0,0,0
        canvas.SetColor(1,1,1)
        canvas.DrawImage(mygrid.image,0,0)   
        mymachine.draw(canvas)
        canvas.SetColor(0,0,1)
        Local x:Int,y:Int
        Local exitloop:Bool=False
        Local switch:Int=0
        While exitloop = False
            Local myangle:Int
            If switch=0 Then myangle=angle Else myangle=360-angle
            canvas.DrawImage(myarrow.image,x,y,myangle)
            switch+=1           
            If switch=2 Then switch=0
            x+=164       
            If x>DeviceWidth()+164
                x=0
                y+=96
                If y>DeviceHeight()+96 Then exitloop = True
            End If           
        Wend
        canvas.Flush
    End
End Class

Function Main()
    New MyApp
End
 
On my mac mini, running OSX 10.14.5 HTML5 and Desktop look the same. No black boxes.
 
It's getting weirder. I thought I'll test again. This is what I got this time.

625
 
Weird. But i am afraid i can't help here. Renders fine here.
 
A third time gives a third result. This one should give a clue for someone I hope. You can see letters very clearly.
It is as if the arrows are drawn on some residue each time instead of on top of a clear canvas.

I might add that Mojo2 always works great otherwise. It's just this example that behaves like this.


626
 
This fixed it.

Code:
Method createimage()
        imagecanvas.Clear 0,0,0,0  '  clear
        imagecanvas.SetColor 1,1,1
        Local w:Float=image.Width()
        Local h:Float=image.Height()
        Local pol:Float[14]
        pol[0] = 0
        pol[1] = h/2       
        pol[2] = w/3
        pol[3] = h       
        pol[4] = w/3
        pol[5] = h/1.5       
        pol[6] = w
        pol[7] = h/1.5       
        pol[8] = w
        pol[9] = h/3       
        pol[10] = w/3
        pol[11] = 0+h/3       
        pol[12] = w/3
        pol[13] = 0
        imagecanvas.DrawPoly(pol)
        imagecanvas.Flush
    End Method
End Class
 
Hello,
Under Linux (Lubuntu 18.04 32 bits) these graphic errors are not seen.
Regards R.-

628
 
@MikeHart @rickychus
Thanks for validating!

Wonder if it is graphiccard-specific then? I got a Intel HD 6000 (Mid 2015 MacBook Air).
I had this demo for a while and.I can add that I've never seen this error on other machines or under Monkey-X.
 
Wonder if it is graphiccard-specific then? I got a Intel HD 6000 (Mid 2015 MacBook Air).
Good morning. Guess what, I got this weird behaviour now too.

629


And the image below the arrow is the logo from the help pages. So the memory of the image is already preloaded with something.
Without clearing it, it will draw whatever it finds.
 
Hello,
My Netbook has an intel atom N2600 (2012), graphics GMA 3600. Pretty old compared to what there is now. It works well in this PC on Linux.
Mike made the error happen on his PC, But in mine it does not happen.
Maybe it's the way the OS manages the graphic memory?
Regards R.-
 
Maybe it's the way the OS manages the graphic memory?

I think that is exactly what is happening here. OSX is doing it differently. And I am not tempted to dig into this. Sooner or later I will have to look into implementing Metal for Apple's platforms and then we will see how it is behaving.
 
I'm certain that this bug came around when Mark made Monkey 87a. It will always work in 86e, for you who have Monkey-X 86e you can try it yourself. On all hardware and OS I own it works.

In version 87a it went unstable like above. Mojo2 also became slower.
 
Back
Top Bottom