LWJGLTextureRenderer cleanup bug?

While solving a FBO leak in my code, I discovered a possible problem in the cleanup() method of the LWJGLTextureRenderer.



ORIGINAL


    public void cleanup() {
        if (!isSupported) {
            return;
        }

        if (fboID > 0) {
            IntBuffer id = BufferUtils.createIntBuffer(1);
            id.put(fboID);
            EXTFramebufferObject.glDeleteFramebuffersEXT(id);
        }
    }



Mmmh, the id.put(fboID) moves the buffer position forward, so the glDeleteFramebuffersEXT() will not get the right id as it does not rewind().


IT SHOULD IT BE LIKE THIS:

    public void cleanup() {
        if (!isSupported) {
            return;
        }

        if (fboID > 0) {
            IntBuffer id = BufferUtils.createIntBuffer(1);
            id.put(0,fboID);
            EXTFramebufferObject.glDeleteFramebuffersEXT(id);
        }
    }



Cheers!


Looks like that a similar problem is also present when deleting textures (GL11.glDeleteTextures()) in:

- LWJGLPbufferTextureRenderer.setupTexture()

- LWJGLTextureRenderer.setupTexture()


Mik of ClassX

By the time someone evaluates the issues, I fixed LWJGLTextureRenderer and LWJGLPbufferTextureRenderer in in my local JME 1.x copy and everything now works as expected.



Of course it would be good to hear some comments.

i dont know how and when this cleanup() method is called. i applied the changes locally too and for me it works as before. however, this seems like a bug and one of the elderlies }:-@ should have a look at it :wink:



so long,

Andy.

Thanks Andy,



it's surely a subtle nasty bug. The same bud I had in my GFX library: textures and FBOs will never released after use  :-o.



Let's wait for an official fix in the CVS…



Mik

There is a jme bug tracker - suggest you put it in there so it doesnt get lost

FWIW, this is already fixed in jme2

ah … id.rewind() does the trick too … :wink: