Monkey2 conversion

About Monkey 2 Forums Monkey 2 Programming Help Monkey2 conversion

This topic contains 19 replies, has 3 voices, and was last updated by  PhatPeter 1 year, 4 months ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #11866

    PhatPeter
    Participant

    So I’ve had a sleepless week while trying to convert this source into Monkey2 but I never quiet succeeded, still bumping into all sorts of problems. Anyone here good at Monkey1 and want to help out?

    It’s the base for an efficient shader and tile engine, It would also make a great example for Monkey2 to build things upon.

    [/crayon]
    #11885

    PhatPeter
    Participant

    The reason I as is that I really need to draw a texture onto itself efficiently in Monkey2.

    Separate experiments went well but throwing everything together made it a snail 🙁

    Mx did it without resorting to opengl so if M2 differ in its implementation I would need to know how to be able to optimise things back. Are there examples on how to effeciently draw parts of an image onto itself and then draw that in turn onto the canvas? This chain of events are what seem to slow down everything in MX2. Do you need to do Ping pong rendering to do that? I don’t think the source above does it.

    The MX source above produce exactly this and it does it well despite being so simple and straightforward. It gives you at least one layer of 64×64 of (shaded) tiles on all Android devices that I´ve tried so far. It’s a good minimum spec. On a PC or Mac you get 16-180 layers(!)

    Doing this as efficitly on Monkey2 is the hardest bit when switching to Monkey2 for me.

    #11888

    abakobo
    Participant

    I’m not sure to understand what you’re looking for but may be pixmaps are what you need!? It helped me to boost some processes sometimes.

    with the PastePixmap for example. And you can modify pixmaps pixels using direct pointer access too (for plot by plot faster drawing. There’s is also discussions about shaders in the help forums too.

    #11889

    PhatPeter
    Participant

    It’s such a simple problem but I probably said it wrong.

    Say that you want to do this
    – You want to draw thousands of images to the canvas, no performance issue.
    – You might draw equally many images onto another image, no problem (it even outperforms the canvas, probably due to that images are often smaller, it’s really nice).

    The problem is the actual combo, and it’s an important combo to have in the toolbox.

    Of course this is not about a once-initiated-pre-drawn-image, it’s about the need to do it continuously.

    MonkeyX does it and the code above proves it even if it lacks the few lines that does the actual cookie-cutting which is just a bunch of DrawRect really.

    Monkey2 on the other hand seem very picky about this?

    This is the only gripe I have with Monkey2 now, I really need it to convert totally.

    #11892

    Mark Sibly
    Keymaster

    Still not quite sure what you mean here…could you try and explain the problem a bit more clearly.

    I assume it’s speed related as there’s mention of snails in there, and that it’s something to do with drawing images to images but beyond that…?

    Ideally, some nice simple runnable monkey2 code with a clear description of the ‘symptoms’ would be ideal!

    #11893

    PhatPeter
    Participant

    This is the best demo I’ve come to manage to produce in Monkey2 as I’m in the process of learning it.
    I could provide full MX code if this M2 can’t put some light on the issue. I’m still new to Monkey2 so bear with me.

    I made a test which uses an untouched image (Barabarian) to blit to the Checkerboard (just another image) and to the main canvas. While doing that it blits some more using the checkerboard as the source and draws onto both itself and the canvas. I would like to throw away the “selfblitting” part and compare, but I think I tried that with similar slow results so that’s not it.

    The test can show that the upper combinations will run fine, while the lower combination one will not.

    If this fails to explain the problem I can show the full source when Mx is doing it, with shader ontop aswell.

    [/crayon]
    Attachments:
    1. This.zip
    #11895

    Mark Sibly
    Keymaster

    Ok, that’s pretty hard to follow, but as far as I can tell you’re trying to draw a texture onto itself, ie: you’re drawing ‘image’ to an ‘icanvas’, where icanvas has the same image as a render target. Please correct me if I’m wrong here…

    Anyway, you can’t do this – it’s technically ‘undefined behaviour’ in opengl/gles/webgl and I’m surprised it works at all!

    If you want to do stuff like this, you need to double buffer, ie: have 2 images/icanvses, and draw image0->icanvas1 and  image1->icanvas0 etc and flip between them.

    #11896

    PhatPeter
    Participant

    Yes I know that it’s undefined to draw to itself but In MonkeyX you can do thath without slowdowns and that’s what makes me confused.

    I use a shader to read sourceimage and process it to targetimage.
    After that I plot some stuff onto targetimage which will therefore be unaffected by the shader, and then I use targetimage as the tilesheet to draw parts onto the canvas.

    But there are self-refference to create a scrolling/rolling effect, and it just works.
    I did some tests without any self-reffering and it’s still as slow in Monkey2.

    Drawing an image that you’ve just draw an image to is expansive in Monkey2.
    The slowdown seem to be x4. 4K draws instead of 16K draws. I would accept that If MonkeyX had the same but it doesn’t.

    #11897

    Mark Sibly
    Keymaster

    It could be anything  – it could be the fact that monkey2 really uses direct3d, whereas monkey-x  uses ‘pure’ opengl, it could be the way I uploaded textures to the driver, the order of API operations I use, whatever…the point is it’s invalid so don’t do it.

    Drawing an image that you’ve just draw an image to is expansive in Monkey2.

    If you have some runnable sample code, please post it, but nothing that uses undefined or invalid behaviour please!

    [edit]You may be right, there may be some sort of issue here, but testing with invalid code is not the right way to find it.

    #11898

    PhatPeter
    Participant

    I managed to simplify things and maybe I’m able to convert everything now I just need help with the corresponding Monkey2 commands for: (the extra commas and zeros and also Image.SetFlagMask Managed).

    [/crayon]
    #11901

    PhatPeter
    Participant

    Any kind soul here? I converted the monkeyX not Monkey2 but it’s not running.

    CONVERSION (MEMORY CRASH)

    [/crayon]

    ORIGINAL MONKEYX (works perfectly with all I’ve said, it would be a nice additional Monkey2 banana)

    [/crayon]
    Attachments:
    1. Files.zip
    #11903

    PhatPeter
    Participant

    No direct X. It’s on macOS. I’ve tried windows (OpenGL via angle) and it shows the same amazing performance there. So both are equally good. It’s the same on both platforms.

    #11904

    Mark Sibly
    Keymaster

    Try building with debug on. You’re missing a ‘=New Int[512,512]’ and an “asset::blah.png”.

    With these fixed I get a smooth scrolling sort of parallax charmap, with random chars all over the place, some sort of animated! Both monkey2 and monkeyx versions look the same to me.

    #11905

    PhatPeter
    Participant

    Your kidding me? haha boy do I feel stupid, 16 hours straight and I miss that.

    Could you list the code because I know not yet how to use “New Int[]”?
    I already include Assets the whole directory?

    #11906

    Mark Sibly
    Keymaster

    I already include Assets the whole directory?

    You need to prefix file name with “asset::” when you load it, eg: Image.Load( “asset::32x32sheet.png” ).

    For texture flags, always use TextureFlags.Dynamic for an image you’re updating frequently (I added some of these I think).

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic.