加载paletted/atitc DDS时Android Opengl ES纹理压缩问题(INVALID_ENUM)
目前,我在 Android 上的 OpenGL ES 1.0 上加载 DDS 压缩纹理时遇到问题(使用压缩器生成):每当我调用 glCompressedTexImage2D 时,我每次都会得到 GL_INVALID_ENUM。这是有问题的代码:
gl.glCompressedTexImage2D(GL11.GL_TEXTURE_2D, -mipMapCount, GL11.GL_PALETTE4_RGBA8_OES, width, height, 0, tsz, texBuf);
变量 tsz
的计算方法是连续将纹理的itchOrLinearSize 除以4,直到它为1 个字节(我的纹理是方形的)。 texBuf 是一个 ByteBuffer 和 mipMapCount。当我这样做时,我收到 GL_INVALID_ENUM 错误代码并且没有加载任何内容。当我加载 ATC 压缩纹理(具有 adreno gpu)时,也会发生同样的情况。
我正在使用模拟器(带有调色板纹理)和我的手机(基于 MSM720x 的芯片组,相当于 HTC Magic,两种类型)进行测试,但没有成功。
这是完整的违规代码:
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_TEXTURE_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;
}
有人知道为什么我会遇到 INVALID_ENUM 错误吗?
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_TEXTURE_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你必须使用“GL_ATC_RGB_AMD”而不是“GL_PALETTE4_RGBA8_OES”
从这里得到:: http://www.brokenteapotstudios.com/android-game-development-blog/2011/07/android-atitc-atc-texture-encoding-and-performance.html
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