AWTTextureIO.newTexture() not creating mipmaps

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

AWTTextureIO.newTexture() not creating mipmaps

Jan Ekholm
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).
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

gouessej
Administrator
Hi

Please write a bug report and reproduce your bug with an existing testcase.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

Jan Ekholm
In reply to this post by Jan Ekholm
I'm such a n00b working with textures so making a test case that actually works (or not in this case) displays a texture would take me ages to do. I can see it in action in my own app by just commenting out the glGenerateMipmap() calls I added.
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

gouessej
Administrator
In this case, don't start from scratch, reuse an existing testcase. In the worst case, write a bug report with no complete test case, it wouldn't be good :s but better than nothing at all.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

Pixelapp
In reply to this post by Jan Ekholm
Given that it used to work before. Try making your texture base of two and the height=width. For example 512x512, 128x128, but NOT 128x64 or 512x128. Let us know what happens.
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

chrtom
In reply to this post by Jan Ekholm
Thank you! Your post saved me a lot of trouble!

glGenerateMipmap is the way to go for OpenGL core profile!

It seems the Texture class does NOT call glGenerateMipmap automatically. I had to do it manually.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: AWTTextureIO.newTexture() not creating mipmaps

gouessej
Administrator
chrtom wrote
It seems the Texture class does NOT call glGenerateMipmap automatically. I had to do it manually.
There are several ways of generating mipmaps and if you set mipmap to true when calling AWTTextureIO.newTexture(), it will generate the mipmaps.
Julien Gouesse | Personal blog | Website