• 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

DrawPrimitives

He is a running example. Just make sure your image has a size of a power of 2:

Cerberus:
' Cerberus X - Draw Primitives2 example
'
' Shows how to construct, draw a list of images via DrawPrimitives

Strict


Import mojo2
'Import cerberus.random


Class MyApp Extends App

    Field myCanvas:Canvas
    Field grabbed:Bool
    Field material:Material
    Field verts:Float[]
    Field texcs:Float[]
    
    Method OnCreate:Int()

        'randomise
        Seed = Millisecs()
        myCanvas = New Canvas()
        
        material = Material.Load("bg.png", Image.Filter,  Shader.DefaultShader())
        If material = Null
        Print ("X")
        endif
        
        ' where to draw
        Local x1:Float = -64
        Local y1:Float = -64
        Local x2:Float = 64
        Local y2:Float = 64
        ' provide 16 vertices from those coordinates as array
        verts = [x1,y1, x2,y1, x2,y2, x1,y2,
                 x1+129,y1, x2+129,y1, x2+129,y2, x1+129,y2,
                 x1,y1+129, x2,y1+129, x2,y2+129, x1,y2+129,
                 x1+129,y1+129, x2+129,y1+129, x2+129,y2+129, x1+129,y2+129]
        ' piece of texture to draw
        Local tx1:Float = 0
        Local ty1:Float = 0
        Local tx2:Float = 1
        Local ty2:Float = 1
        ' provide texture coordinates for vertices
        texcs = [tx1,ty1, tx2,ty1, tx2,ty2, tx1,ty2,
                 tx1,ty1, tx2,ty1, tx2,ty2, tx1,ty2,
                 tx1,ty1, tx2,ty1, tx2,ty2, tx1,ty2,
                 tx1,ty1, tx2,ty1, tx2,ty2, tx1,ty2]
        

        
        Return 0       
    End
    
    Method OnRender:Int()
    
        myCanvas.Clear(1, 1, 1)
        
        Local m:Int = Millisecs()
        myCanvas.SetColor(1, 0, 0)
        myCanvas.DrawText("Move the mouse", DeviceWidth()/2, DeviceHeight() - 16, 0.5)       
        myCanvas.SetColor(1, 1, 1)
        
        myCanvas.PushMatrix()
        myCanvas.Translate(MouseX(), MouseY())
    
        myCanvas.DrawPrimitives(4, 4, verts, texcs, material)
        myCanvas.PopMatrix()

        myCanvas.Flush()
        Return 0
    End
    
    
    Method OnUpdate:Int()
    
        Return 0
    End

End

Function Main:Int()
    New MyApp()
    Return 0
End

But do you have to use floating point now to set coordinates you can't use pixels anymore?
Yes, you do. That is how OpenGL works.
 
AMOS2 has released maybe there's a helpful community there. Here you keep everything good for yourself apparently.
Oh I don't quite like comments like this. Your attitude comes over like "YOU HAVE TO HELP ME" but you didn't show anything that you tried yourself on this specific topic. We are a small community here and when some HAS TIME and stumbled over your problem before, they might help. If they don't, they might not have used that part of CX before and don't know themself. Nobody is forced to help or entitled to get help. For an example, I just looked into this part of Mojo2, never used it before. So if you think a different place is better for your needs, then by all means, go there and don't let the door hit you in the back. I would be happy you stay, but don't act like this here.
 
I adore you for your inspiring and passionate spirit..

Why demanding and accusing people for being not active enough in trying their best before asking something, Maybe you simply enjoy doing it.

First of all I'm not one of those people, and most of all; I don't want be among your kind.
 
This thread is going off-topic...

Listen, we know a lot of the commands could use better explanation and/or examples. And yes, since the language CX is open source it grows with the community and here and there a command slips in of which only a few know how it works - so it might totally look as if we were keeping secrets. But! Don't bite the hand that feeds you. You asked for an explanation of those two commands and we delivered. Yes it took a while and no, no one is obliged answer faster. We're all here by choice. And lastly: Yes, one could have answered your question without a single line of code
or at least have started to steer the discussion in the right direction with simpler inputs. But this doesn't make your comment any less inappropriate.

We're a small community here, and as every community we can only work when we're nice to each other. We don't want to be a st*ckoverflow where mods swing the banhammer and just close topics they don't understand and the whole community is forced into a behaviour with a scoring system - we try to become the happy niche board where we raise our guests by direct, but honest reminders.

TL;DR: You're always allowed to ask questions, but don't get pissed when a question isn't answered immediately. And if you do, find other words to express that ;)
 
I adore you for your inspiring and passionate spirit..

Come on @RaspberryDJ, that's not fair. One post further up this thread isn't representative of the help you've received from @MikeHart and several other other members - I've just checked your recent threads and they've all received helpful replies. Believe me I know how frustrating CX can be at times but lashing out at people won't get you anywhere. Mike and Holzchopf have both provided example code to this question, I don't know what else you could ask for in a free and open source project.
 
Back
Top Bottom