Transparent rectangular region via open gl

This topic contains 3 replies, has 2 voices, and was last updated by  Joe Davis 3 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #31746

    i m trying to generate draw using opengl and leave a part of screen alone transparent.

    i tried blending with alpha and stencil.
    i have always get a black color in the stencil region. i m unable to get the black region as transperent/ not paint via opengl.

    i tried scissor but it cuts to rectangular view port. i m unable to achive what i want.

    also copy pixel will not work for me as transparent part of the screen will be changed on the fly during opengl commands.

    i doubt swapbuffer is putting everything to screen and i checked the alpha blending eg. there too its same if i remove the background opaque i get the black color.

    is there something i stop particular region of the window not be updated by swapbuffer.

    Do anyone know how to create transparent region in a opengl. sample code will help.


    Joe Davis


    We will need more information before we can help you:

    1. What operating system are you targeting?
    2. What graphics API are you using (e.g. OpenGL ES 2.0)?
    3. Are you targeting a device with a PowerVR GPU? If not, are you using our PVRVFrame emulation?
    4. Can you share a screenshot or mockup that shows what your render should look like when rendering correctly?
    5. Can you share a binary, source code or PVRTrace recording of your application so we can try to reproduce the issue?



    hi Joe,

    I m trying to achieve a transparent background for a certain region in my opengl window.

    i draw something in background without opengl.

    and then i drawing some thing on screen using opengl mask the overlapping region with stencil/alpha but i see a black region rather than back

    i m trying openglES2.0 in mac 10.9.

    if you see in the above pic
    1.) blue color is the window drawn by opengl
    2.) black rectangle box is the region i m trying to make it transparent so i can see image/red color in background.

    Can we achieve this?


    Joe Davis


    As you only have a single surface, the CPU is writing data to it and then the GPU render is setting a view port within the same surface and rendering to it. It’s not possible to blend the GPU rendered area with the existing surface data, as GL will ignore the existing data and merely write to the surface. I suspect that the black region is actually undefined data from the GPU.

    Instead, you should create “off-screen” two surfaces (one for the CPU render, another for the GPU render) and compose them into your window surface. The easiest way to do this would be to upload your CPU rendered surface as a texture in GL, render your GPU rendered overlay to an FBO, and then compose the two surfaces in a final render pass to the main framebuffer.


Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.