[PyOpenGL-Users] Compressed Textures
Brought to you by:
mcfletch
|
From: Alejandro S. <as...@gm...> - 2014-09-27 17:02:58
|
Hey guys,
I'm having trouble figuring out how the binding works for the S3TC
compressed textures extension.
Here's the relevant snippet:
from OpenGL import extensions
if not extensions.hasGLExtension("GL_EXT_texture_compression_s3tc"):
print "Extension GL_EXT_texture_compression_s3tc required for texture
mapping!"
os.abort()
img = pygame.image.load(“diff.png”)
raw = pygame.image.tostring(img, "RGB")
diff_tex = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, diff_tex)
glCompressedTexImage2DARB(GL_TEXTURE_2D, 0,
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, img.get_width(), img.get_height(), 0,
len(raw), raw)
This is raising an Invalid Value GL error:
err = 1281,
description = 'invalid value',
baseOperation = glCompressedTexImage2DARB,
According to the GL docs, invalid value is raised if the size parameter
specified does not match the passed-in byte array, which it should, since
it's just a len() of the data. I also tried width * height * 3, but to no
avail.
I'm using pygame to read the image and convert it into a string (byte
array), which works fine with glTextImage2D, but seems to fail for this
extension.
Has any of you ever encountered something similar? I'm pretty sure I must
be missing something related to the binding, but can't seem to figure out
what.
Thanks in advance,
Alejandro.-
|