Login  Register

Re: Correct example for texture compression?

Posted by aqd on Apr 17, 2015; 1:12pm
URL: https://forum.jogamp.org/Correct-example-for-compressed-texture-allocation-tp4034307p4034309.html

I added error checks everywhere and located the problem: glFramebufferTexture2D

The texture is to be used with framebuffer (to store whatever painted onto it), and glFramebufferTexture2D throws "invalid framebuffer operation" when the given texture's internal format is DXT3/DXT5, but no error when it's just RGBA8.

But why? It doesn't seem to be documented anywhere.

Here is the simplified code - it turns out WWJ is using TextureData for empty texture allocation and I can just skip it to save the confusion.

        int internalFormat = GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
        int pixelFormat = GL.GL_RGBA;
        GL gl = dc.getGL();
        Texture t = new Texture(0, GL.GL_TEXTURE_2D, width, height, width, height, false);
        t.bind(gl);
        gl.glTexImage2D(t.getTarget(), 0, internalFormat,
                width, height, 0,
                pixelFormat, GL.GL_UNSIGNED_BYTE, null);
        gl.glTexParameteri(t.getTarget(), GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
        gl.glTexParameteri(t.getTarget(), GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
        gl.glTexParameteri(t.getTarget(), GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
        gl.glTexParameteri(t.getTarget(), GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);