Login  Register

Texture NPOT

Posted by paolofuse on Sep 14, 2015; 7:49am
URL: https://forum.jogamp.org/Texture-NPOT-tp4035280.html

Hi all,
I have a problem with NPOT texture.

Texture texture = TextureIO.newTexture(new File(filename), true);

This code works with POT and NPOT textures:

gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glBindTexture(GL2.GL_TEXTURE_2D, texture.getTextureObject());
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2d(0, 0);
gl.glVertex2d(0, 0);
gl.glTexCoord2d(1, 0);
gl.glVertex2d(texture.getWidth(), 0);
gl.glTexCoord2d(1, 1);
gl.glVertex2d(texture.getWidth(), texture.getHeight());
gl.glTexCoord2d(0, 1);
gl.glVertex2d(0, texture.getHeight());
gl.glEnd();
gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);

This code works only with POT textures:

texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2d(0, 0);
gl.glVertex2d(0, 0);
gl.glTexCoord2d(1, 0);
gl.glVertex2d(texture.getWidth(), 0);
gl.glTexCoord2d(1, 1);
gl.glVertex2d(texture.getWidth(), texture.getHeight());
gl.glTexCoord2d(0, 1);
gl.glVertex2d(0, texture.getHeight());
gl.glEnd();
texture.disable(gl);

I need to use the last code with NPOT textures.
I'm working on a Mac Book Pro with OSX 10.10.5 and an AMD Radeon HD 6490M video card.

Any suggestion?
Thanks in advance.
paolofuse