Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8607357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:20:13+00:00 2026-06-12T03:20:13+00:00

Using OpenGL ES 2.0 on iOS 4 . I have an OpenGL view that

  • 0

Using OpenGL ES 2.0 on iOS 4.

I have an OpenGL view that inherits from UIView. It is in front of a UIImageView that provides a background.

I have a .png image with transparency that I am using for an OpenGL texture.

The problem I am having is the transparency of the image in the OpenGL view shows through to the image in the UIImageView background. I would like to show content in the OpenGL view that is behind the elements with the transparent texture.

The underneath OpenGL texture is being rendered, but any portion that has the transparent texture on top does not show the underneath OpenGL texture. It shows the UIImageView background.

What do I need to do so that the transparency will show content in the OpenGL view that is behind the transparent content?

EDIT:

I restructured the index array so all elements with transparent textures come at the end and should be rendered after all opaque elements when I call glDrawElements.

Still having the problem with the transparency.

I set up some data so that I have 4 vertices and 6 indices for 2 triangles to draw a square with the opaque texture.
There are also 4 vertices and 6 indices for 2 triangles to draw a square with the transparent texture which come after the other entries in the vertex/index arrays. The transparent element coordinates render it in front of the opaque element.

I can see the transparent element, and I can also see the edges of the opaque element sticking out from behind.
However, instead of showing the opaque element which lies immediately behind the transparent element, the transparency goes right through and shows the background of the view behind the OpenGL view.

Opaque yellow square:

Opaque yellow square

Transparent test image:

Transparent test image

The transparent image covers the opaque image but the transparency shows the background not the opaque image behind:

enter image description hereenter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:20:15+00:00Added an answer on June 12, 2026 at 3:20 am

    Did you try using some blending? Something like this:

    //draw your background scene here
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //draw your foreground scene here
    glDisable(GL_BLEND);
    

    —————–EDIT on comment—————-

    So you want to do the blending in fragment shader:

    vec4 color1 = texture2D(backgroundTexture, ...);
    vec4 color2 = colorYouGetFromSecondaryTextureOrSomeOtherElement;
    
    vec4 outputColor = color1*(1.0-color2.a) + color2*(color2.a);
    outputColor.a = 1.0; //or some function of color1.a and color2.a
    
    gl_FragColor = outputColor;
    

    —————–EDIT 2————————-

    Also considering your results I would say that you forgot something in your pipeline. You probably use 2 or more textures but only your second is binded resulting in the fragment snippet I posted to be all black but your foreground.. Are you using “active texture”? Something like this:

    - (void)bindFirstTexture {
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_1D, firstTextureID);
    }
    - (void)bindSecondTexture {
        glActiveTexture(GL_TEXTURE1);
        glBindTexture(GL_TEXTURE_2D, secondTextureID);
    }
    

    You need such binding in both, before creating and before drawing multiple textures.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting from the Apple-spupplied iOS OpenGL game template in Xcode and I have
new to IOS OpenGL programming. I have worked through a few tutorials that talk
I'm using OpenGL ES to display some objects exported from Blender. Blender provides a
I'm using an OpenGL framebuffer object (FBO) to implement stencil shadows on iOS. The
Using OpenGL ES I am rendering a simple cube class that draws it at
I have created a Universal app using Interface Builder. My view controllers are embedded
I have a radial gradient texture (RGBA) that goes from a black fully opaque
I'm starting to work with OpenGL in iOS. I have always learned to draw
I have a problem using opengl on android to draw a simple rectangle. This
I am developing static library that takes screenshots, and taking them from OpenGL applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.