Question

I've written a test program using OpenGL on OS X that loads a PNG, compresses it in memory to DXT5 using libsquish (http://code.google.com/p/libsquish/), and textures a plane.

When I upload an image that contains an alpha channel, but no pixels have alpha values other than fully opaque, it displays correctly: http://i.imgur.com/nElZ8.png

Given the same image but the black part is replaced with transparency, this is the output I get: http://i.imgur.com/8Ld3y.png

The code is not pretty, it is a thrown together proof of concept:

  1. The C++ source: http://pastebin.com/m0RqpgUS
  2. The vertex shader: http://pastebin.com/QyaWCaTk
  3. The fragment shader: http://pastebin.com/KEuFJ83C
  4. The test images: http://dl.dropbox.com/u/4597377/images.zip

Any thoughts?

Was it helpful?

Solution

Turns out I forgot this:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top