开发者

Opengl compressed texture with lwjgl

I have a DXT1 texture loaded in a ByteBuffer and I'm trying to load it with Opengl

int tID = glGenTextures();
glBindTexture(GL_TEXTURE_2D, tID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, w, h, 0, imag开发者_运维问答eData);
System.out.println(gluErrorString(glGetError()));

It's giving me the error "Invalid Operation" on the glCompressedTexImage2D call. Can't seem to figure out why.


Ok i figured out what the problem was. The size of imageData was incorrect. Since DXT1 is 4 bits per pixel, i kept thinking it should be w * h * 4. It should have been w * h * 1/2 (4 bits being 1/2 a byte).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜