OpenGL background transparency?

I am using QT QGLFramebufferObject for off-screen display.
After rendering to the buffer, I read the result using glReadPixels ()
The problem is that sometimes the background color I am reading is 0 (transparent black) and sometimes it is 0xFF000000 (opaque black)
This is similar to the buffer initialization time. If the buffer is a member of a class inherited from QGLWidget, then it is 0. If it is initialized elsewhere, it is 0xFF000000.

Does anyone know what's going on here? What is the good expected result of this reading?

+1


source to share


2 answers


Have you set the correct transparent color (glClearColor) and actually clear (glClear)? Make sure the glColorMask is fully enabled (it also affects clearing). Then you can check if QT has some weird pixel copy transfer set up (other than the default, see glPixelStore, glPixelTransfer and glPixelMap). Are you sure you are getting (and reading) an RGBA buffer in both cases, not just RGB? Finally, it is entirely possible that extending the framebuffer object does not work on your particular video card / driver combination, even more so if there is no main window visible. At least check the cards with both providers. And of course, always check glGetError after all possible failures. After re-reading your question,will you get any other valid rendering at all in the non-QGLWidget case? Is it clear to say green, green? As it is entirely possible that you just haven't initialized any valid OpenGL context to get started in this case. Framebuffers, unlike pbuffers, need an external context.



+1


source


Mystery Solved
It seems that the clear color I pass to GLWidget is 0 and the default clear color is 0xff000000. Depending on when I initialize the framebuffer object, it gets the current transparent color of the GLWidget.



0


source







All Articles