Login  Register

Non-power of 2 textures no longer working?

Posted by nick.collier on Oct 17, 2013; 7:44pm
URL: https://forum.jogamp.org/Non-power-of-2-textures-no-longer-working-tp4030292.html

We'd like to update to the 2.1.0 release and are doing some tests. It looks like non-power 2 textures don't work, although in a previous build (981) they seemed to have done. Here's the code:

texture = AWTTextureIO.newTexture(gl.getGLProfile(), img, true);
  
// this returns true in 2.1.0
    System.out.println(gl.isNPOTTextureAvailable());
    
    float width = texture.getWidth() / 2f;
    float height = texture.getHeight() / 2f;
    
    listIndex = gl.glGenLists(1);
    gl.glNewList(listIndex, GL2.GL_COMPILE);
    gl.glBegin(GL2.GL_QUADS);

    TextureCoords tc = texture.getImageTexCoords();
    gl.glTexCoord2f(tc.left(), tc.bottom());
    gl.glVertex2f(-width, -height);

    gl.glTexCoord2f(tc.right(), tc.bottom());
    gl.glVertex2f(width, -height);

    gl.glTexCoord2f(tc.right(), tc.top());
    gl.glVertex2f(width, height);

    gl.glTexCoord2f(tc.left(), tc.top());
    gl.glVertex2f(-width, height);
    
    gl.glEnd();
    gl.glEndList();

I realize display lists should no longer be used but this code is old and has been part of our application for a while. Regardless, when I use a 30x30 image in build 981 of jogl the texture renders as expected. If I use the same image in 2.1.0 it doesn't render and there are no error messages. If I resize the image to 32x32 it renders as expected. This occurs on both OSX and Linux, but I haven't tested on windows. Anyway, I can try to make a proper bug report if the above should actually work with a 30x30 image.

Nick