Login  Register

Correct example for compressed texture allocation?

Posted by aqd on Apr 17, 2015; 11:36am
URL: https://forum.jogamp.org/Correct-example-for-compressed-texture-allocation-tp4034307.html

Hi all! Can anyone point me an example for allocating in-memory texture with compression? Here is my uncompressed example (from World Wind Java)
        TextureData td = new TextureData(
                gl.getGLProfile(),    // GL profile
                GL.GL_RGBA8,          // internal format
                width, height,        // dimension
                0,                    // border
                GL.GL_RGBA,           // pixel format
                GL.GL_UNSIGNED_BYTE,  // pixel type
                this.isUseMipmaps(),  // mipmap
                false, false,         // dataIsCompressed, mustFlipVertically
                null, null);          // buffer, flusher
        Texture t = TextureIO.newTexture(td);
        t.bind(gl);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,
                this.isUseMipmaps() ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
I have tried this and it used to work with DXT3/DXT5/BPTC until this year (driver update I suppose, but was I wrong?)
        TextureData td = new TextureData(
                gl.getGLProfile(),    // GL profile
                GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,       // internal format
                width, height,        // dimension
                0,                    // border
                GL.GL_RGBA,           // pixel format
                GL.GL_UNSIGNED_BYTE,  // pixel type
                this.isUseMipmaps(),  // mipmap
                false, false,         // dataIsCompressed, mustFlipVertically
                null, null);          // buffer, flusher
        Texture t = TextureIO.newTexture(td);
        t.bind(gl);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,
                this.isUseMipmaps() ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
        gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
(I didn't set dataIsCompressed=true or assign the buffer)

mip-map is off. It used to work fine on nVIDIA card (there are artifacts on AMD's).

But now it shows complete garbage like this:

PS: The garbage parts are the compressed texture tiles. But I can still load DXT3/DXT5 from files.