Buffer undefined result (3 posts)

  • Profile picture of tralala tralala24p said 3 months, 2 weeks ago:

    hello, for my sprite lib.

    when i create a buffer with bigger size that the number of sprites i use, the rest of the positions have undefined result.

    ok but the real problem is this.

    jme shader can read the buffer beyond the limit. E.g it reads positions [limit, capacity]

  • Profile picture of tralala tralala24p said 3 months, 2 weeks ago:

    ok, i found the problem and fixed my code. The problem was .flip(); method in buffer, after i removed it, it run normally.

    Bug : flip(); creates undefined numbers at [limit, capacity] area, so it gives garbage results to the shader. Can you fix that bug in jme ?

    Here is what i do:
    a) create a buffer with all zeroes [0,capacity]
    b) when i want to “set” a sprite i only chance the corresponding position. I leave the rest unmodified(the zeroes mean empty sprite).
    c) it works fine.

    d) bug: if i dared reduce the area to [0, max_sprites] with .flip();
    jme would create garbage at [limit = max_sprites, capacity]
    i would only use .flip() to reduce the amount of data transfered to gpu to increase fps. But it doesn’t work.

    so due to this bug the speed of the application depends on the size of the buffer initially created and not the number of sprites.

    any ideas ?

  • Profile picture of tralala tralala24p said 3 months, 2 weeks ago:

    According to java specification (http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/Buffer.html ):

    A buffer’s limit is the index of the first element that should not be read or written.

    And jme’s shaders read beyond the limit, so they violate java’s specification.
    Which means that this is a bug with jme.