Compressed Textures

Alejandro Segovia <[email protected]> Sat, 27 Sep 2014 13:02:30 -0400
Newsgroups gmane.comp.python.opengl.user
Message-ID <CAAXrc9Mr=GHNmk2v21iHdTmenskXmfEb7zkUya3i_q4zOtueYw@mail.gmail.com>
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.-

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users