开发者

Android Opengl ES Texture compression problem when loading a paletted/atitc DDS (INVALID_ENUM)

开发者 https://www.devze.com 2023-04-01 06:52 出处:网络
Currently i\'m having a problem loading a DDS compressed texture on OpenGL ES 1.0 on android (generated using The Compressonator): whenever i call glCompressedTexImage2D i get a GL_INVALID_ENUM everyt

Currently i'm having a problem loading a DDS compressed texture on OpenGL ES 1.0 on android (generated using The Compressonator): whenever i call glCompressedTexImage2D i get a GL_INVALID_ENUM everytime. Here's the code in question:

gl.glCompressedTexImage2D(GL11.GL_TEXTURE_2D, -mipMapCount, GL11.GL_PALETTE4_RGBA8_OES, width, height, 0, tsz, texBuf);

The variable tsz is calculated as succesive dividing in 4 the pitchOrLinearSize of the texture until it is 1 byte (my textures are square). texBuf is a ByteBuffer and mipMapCount. When i do this i obtain a GL_INVALID_ENUM error code and nothing loads. The same occurs when i load the ATC compressed texture (have an adreno gpu).

I'm testing with the Emulator (with paletted textures) and my phone (MSM720x based chipset, equivalent to the HTC Magic, with both types) to no avail.

Here's the complete offending code:

                        ByteBuffer texBuf = ByteBuffer.allocateDirect(tsz);
                        int ld = fis.getChannel().read(texBuf);
                        if (ld == tsz) {
                            int id = newTextureID(gl);
                            gl.glBindTexture(GL11.GL_TEXTURE_2D, id);

                            // Set all of our texture parameters:
                            gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
                            gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
                            gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
                            gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

                            texBuf.position(0);
                            //gl.glCompressedTexImage2D(GL11.GL_TEXTURE_2D, -mipMapCount, GL11.GL_PALETTE4_RGBA8_OES, width, height, 0, tsz, texBuf);
                            gl.glCompressedTexImage2D(GL11.GL_TEX开发者_C百科TURE_2D, -mipMapCount, GL11.GL_PALETTE4_RGBA8_OES, width, height, 0, pitchOrLinearSize, texBuf);

                            int err = gl.glGetError();

                            if (err == GL11.GL_INVALID_VALUE) {
                                Log.d("TDL-dds", "Error INVALID_VALUE");
                            } else if (err == GL11.GL_INVALID_ENUM) {
                                Log.d("TDL-dds", "Error INVALID_ENUM");
                            }

                            if (err != 0) {
                                int texs[] = new int[1];
                                texs[0] = id;
                                gl.glDeleteTextures(1, texs, 0);
                                return 0;
                            }
                            return id;
                        }

Anyone knows why i'm having that error of INVALID_ENUM?


I think you have to use 'GL_ATC_RGB_AMD' instead of 'GL_PALETTE4_RGBA8_OES'

Got that from here:: http://www.brokenteapotstudios.com/android-game-development-blog/2011/07/android-atitc-atc-texture-encoding-and-performance.html

0

精彩评论

暂无评论...
验证码 换一张
取 消