AWTTextureIO.newTexture() not creating mipmaps
Posted by Jan Ekholm on
URL: https://forum.jogamp.org/AWTTextureIO-newTexture-not-creating-mipmaps-tp4029093.html
I have some code that worked nicely with a JOGL from late 2012. Today I revisited the code and noticed that some simple textured quads had no textures but were rendering as black. Trigger an epic 10h bug hunt in my own code with a few curses and some rants.
The culprit seems to be that AWTTextureIO.newTexture() or TextureIO.newTexture() no longer create mipmaps automatically. The code that worked fine looked like:
Texture m_loadingTexture;
...
m_loadingTexture = AWTTextureIO.newTexture( getClass().getResource( "Textures/Loading.png" ), true, TextureIO.PNG );
m_loadingTexture.setTexParameteri( gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR );
m_loadingTexture.setTexParameteri( gl, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR );
m_loadingTexture.setTexParameteri( gl, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT );
m_loadingTexture.setTexParameteri( gl, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT );
...
gl.glActiveTexture( GL.GL_TEXTURE0 );
m_noContentTexture.bind( gl );
gl.glUniform1i( gl.glGetUniformLocation( m_noContentShaderProgram.program(), "uTexture" ), 0 );
etc.
The texture was loaded ok and nicely rendered. Today it was black. Note the "true" parameter to AWTTextureIO.newTexture() which according to the docs is supposed to automatically create mipmaps and did with the old JOGL. Now it doesn't and nothing worked before I added:
gl.glGenerateMipmap( GL.GL_TEXTURE_2D );
after loading the texture. If this is intended behaviour then the docs for the parameter could be improved a little bit and the general usefulness of TextureIO is reduced a bit compared to just loading an image and doing the low level OpenGL calls manually.
I didn't report this as a bug as Bugzilla requires registration and I'm not sure it's a real bug (but after my wasted 10h I'd be ready to call it a lot of things that are not safe for sensitive ears and eyes).