DrawRect usage?

About Monkey 2 Forums Monkey 2 Programming Help DrawRect usage?

This topic contains 3 replies, has 2 voices, and was last updated by  Ethernaut 1 year, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11744

    PhatPeter
    Participant

    If you try this code with any sprite-sheet of 32×32 tiles then you’ll notice the pixels will bleed.
    Is this the classic bleeding OpenGL bug in some sense or am I just using it wrong?

    [/crayon]
    #11790

    PhatPeter
    Participant

    I upload the whole package here, maybe someone knows how to fix the glitch?

    Attachments:
    1. Glitchy.zip
    #11792

    PhatPeter
    Participant

    I think I solved it myself, the x & y needs to be Int instead of Float.

    #11817

    Ethernaut
    Participant

    Using ints will solve it, but sometimes you want fractional coordinates (i.e. HD sprites, non “retro” 2D games).

    For those cases, the only solution I know of is to add a gap between each tile, and copy the color of each edge pixel to the corresponding gap pixel.

    I used to do this using Photoshop actions, but it was really annoying since you had to keep two sets of images – the original ones, and the ones with the colored gap…

    …So I made a Monkey module to deal with that “on the fly”! (this feature is still alpha)
    https://github.com/DoctorWhoof/spriteTools

    Here’s how it works:
    Once you load a PNG file, the Atlas class internally generates the gaps between tiles, even if they were created without gaps, and creates a texture atlas from that. You can then use Atlas.Cells[ index ] to access each individual image.

    And as a bonus, it converts any source image file into a “Power of Two” sized atlas, more guaranteed to work in all kinds of GPUs without artifacts like unwanted scaling.


    Totally untested in real production! Let me know if it works.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.