trivial OpenGL question

Why do I always get opaque (ARGB 0xFF000000) black pixels when grabbing an empty, cleared opengl buffer ?
I expected each pixel to be clear and transparent (ARGB 0x000000) and not opaque black.

here’s my setup:

glState.glDisable(GL_SCISSOR_TEST);
glState.glDisable(GL_DEPTH_TEST);
glState.glEnable(GL_ALPHA_TEST);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black transparent Background
gl.glClearDepth(1.0f); // Depth Buffer Setup
gl.glDepthFunc(GL_LEQUAL); // Type Of Depth Testing
glState.glEnable(GL_DEPTH_TEST); // Enable Depth Testing
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glState.glEnable(GL_BLEND);

Note that glGetIntegerv(GL_ALPHA_BITS,…) gives 0 (ZERO).

Mik

Random ideas:
If you’ve not got any alpha bits in the framebuffer, then its probably ignoring all operations that act on it (like glClearColor’s 4 param) and just giving you back the default when you use glReadPixels.

The simplest way to fix that would be to request some alpha bits, then it’ll work as expected (but due to Jogl being buggy, you then make your app not work on linux >:( ).

Or you could just change your glReadPixels (or whatever). If you’ve only got RGB it doesn’t make sense to try and get RGBA.

Cute solutions, but …ahem… can you explain better (code snippets needed here)

I’m just a beginner :-[ (and using GL4Java (and trying to get a better Agile2D)).

Mik

When you set up an OpenGL window, you have to ask it specifically for alpha bits. If you don’t, alpha is unspecified in the framebuffer; and unspecified alpha is always “opaque”. Hence no matter what alpha values to try and write to the framebuffer, they’re simply being discarded, and a read from the framebuffer into RGBA colour gives you an alpha of 255, completely opaque.

Cas :slight_smile:

Thanks Pepe, I imagined something like this.

How can I setup the alpha plane then ?