Log in or register to post comments

alpha blending

December 14, 2010 - 2:00am #1

I'd like to use alpha blending effects with my rendering.

I see that's there is function which ask QCAR if alpha channel is needed to setup the EGL context.

If i want alpha, should i just change this method to always return "true", or should i tell QCAR that I need alpha?


Re: alpha blending

December 15, 2010 - 8:28am #6

No, if the GL context is set to use RGB565 there will not be an alpha channel. This does not prevent blending from working, however. OpenGL performs the blending functions before setting the final color in the RGB565 buffer, so you don't actually need an alpha channel for basic blending to work.

RBG565 is the typical context used for handheld devices, for performance reasons. In fact, even the Unity engine uses this by default. You may have to adjust your blending functions if you are doing something particularly fancy, but for most basic blending techniques things should work the same. This especially includes the use of the "standard" blending function:


What blending functions were you planning on using?

- Kim

Re: alpha blending

December 15, 2010 - 7:51am #5

ok RGB565 should be enough, but if translucent is false
this code in QCARSampleGLView will not setup the alpha channel for the OpenGL context

setEGLConfigChooser( translucent ?
new ConfigChooser(8, 8, 8, 8, depth, stencil) :
new ConfigChooser(5, 6, 5, 0, depth, stencil) );

or even if alpha = 0 the ConfigChoose will still try to find a config with an alpha channel?

Re: alpha blending

December 15, 2010 - 6:48am #4

That function is used to set an alpha channel for the entire OpenGL layer, such that it can blend with layers behind it. On some devices, our SDK may use this technique for rendering the OpenGL layer over a separate camera layer. On most devices, however, QCAR.requiresAlpha() will return false, and you will have a RGB565 OpenGL context.

I believe that for most blending techniques a RGB565 context is sufficient, but if you really need a RGBA8888 context you should be able to set the translucent flag yourself. It could be harmful to set this flag to false (as some devices might then lose the camera background image) but setting it to true for your own blending techniques shouldn't be a problem. Let us know if you run into any issues though!

- Kim

Re: alpha blending

December 15, 2010 - 3:24am #3

ok but my concern is about QCAR.requiresAlpha()

boolean translucent = QCAR.requiresAlpha();

mGlView = new QCARSampleGLView(this);
mGlView.init(mQCARFlags, translucent, depthSize, stencilSize);

this is what tell how to setup the EGL context, the alpha channel is dependent of QCAR.requiresAlpha().

question: what return this function, and what parameters change the return value?

Re: alpha blending

December 14, 2010 - 7:32am #2

You shouldn't have to use that alpha channel function, it is for internal use only (it affects the entire OpenGL layer, not content within the layer).

For OpenGL content, it is sufficient to use the typical blending functions. As a test, I opened the teapot textures in Photoshop at set the opacity levels to 50%. In the ImageTargets.cpp file, I added the following to the renderFrame method:


With this setting, the teapot is properly blended against the background. Let us know if there is any particular blending technique that isn't working as expected!

- Kim

Log in or register to post comments