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 6570567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:46:19+00:00 2026-05-25T14:46:19+00:00

I read iOS OpenGL ES Logical Buffer Loads that a performance gain can be

  • 0

I read iOS OpenGL ES Logical Buffer Loads that a performance gain can be reached by “discarding” your depth buffer after each draw cycle. I try this, but it’s as my game engine is not rendering any longer. I am getting an glError 1286, or GL_INVALID_FRAMEBUFFER_OPERATION_EXT, when I try to render the next cycle.

I get the feeling I need to initialize or setup the depth buffer each cycle if I’m going to discard it, but I can’t seem to find any information on this. Here is how I init the depth buffer (all buffers, actually):

    // ---- GENERAL INIT ---- //        
    // Extract width and height.
    int bufferWidth, bufferHeight;
    glGetRenderbufferParameteriv(GL_RENDERBUFFER,
                                 GL_RENDERBUFFER_WIDTH, &bufferWidth);
    glGetRenderbufferParameteriv(GL_RENDERBUFFER,
                                 GL_RENDERBUFFER_HEIGHT, &bufferHeight);

    // Create a depth buffer that has the same size as the color buffer.
    glGenRenderbuffers(1, &m_depthRenderbuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, m_depthRenderbuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, GAMESTATE->GetViewportSize().x, GAMESTATE->GetViewportSize().y);

    // Create the framebuffer object.
    GLuint framebuffer;
    glGenFramebuffers(1, &framebuffer);
    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                              GL_RENDERBUFFER, m_colorRenderbuffer);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                              GL_RENDERBUFFER, m_depthRenderbuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);

And here is what I’m trying to do to discard the depth buffer at the end of each draw cycle:

    // Discard the depth buffer
    const GLenum discards[]  = {GL_DEPTH_ATTACHMENT, GL_COLOR_ATTACHMENT0};
    glBindFramebuffer(GL_FRAMEBUFFER, m_depthRenderbuffer);
    glDiscardFramebufferEXT(GL_FRAMEBUFFER,1,discards);

I call that immediately following all of my draw calls and…

[m_context presentRenderbuffer:GL_RENDERBUFFER];

Any ideas? Any info someone could point me to? I tried reading through Apple’s guide on the subject (where I got the original idea), http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html, but it doesn’t seem to work quite right for me.

  • 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-05-25T14:46:20+00:00Added an answer on May 25, 2026 at 2:46 pm

    Your call to glDiscardFramebufferEXT(GL_FRAMEBUFFER,1,discards) is saying that you are discarding just 1 framebuffer attachment, however your discards array includes two: GL_DEPTH_ATTACHMENT and GL_COLOR_ATTACHMENT0.

    Try changing it to:

    glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, discards);
    

    In fact, you say that you are discarding these framebuffer attachments at the end of the draw cycle, but directly before [m_context presentRenderbuffer:GL_RENDERBUFFER];. You are discarding the colour renderbuffer attachment that you need in order to present the renderbuffer – perhaps try just discarding the depth attachment, as this is no longer needed at this point.

    You only need to initialise your buffers once, not every draw cycle. The glDiscardFramebufferEXT() doesn’t actually delete your framebuffer attachment – it is simply a hint to the API to say that the contents of the renderbuffer are not needed in that draw cycle after the discard command completes. From Apple’s OpenGL ES Programming Guide for iOS:

    A discard operation is defined by the EXT_discard_framebuffer
    extension and is available on iOS 4.0 and later. Discard operations
    should be omitted when your application is running on earlier versions
    of ioS, but included whenever they are available. A discard is a
    performance hint to OpenGL ES; it tells OpenGL ES that the contents of
    one or more renderbuffers are not used by your application after the
    discard command completes. By hinting to OpenGL ES that your
    application does not need the contents of a renderbuffer, the data in
    the buffers can be discarded or expensive tasks to keep the contents
    of those buffers updated can be avoided.

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

Sidebar

Related Questions

I read in the iOS Enterprise Developer Program docs that a provisioning profile can
Can an iOS app read a file that has been placed on that device
I have to develop an iOS application that can read the data from a
iOS 5's storyboard is awesome but I've read that it would be better to
I am building a read-only iOS application that will ship with a default SQLite
I read a lot about how MT works, that it binds to the iOS's
I am starting to think that short of OpenGL I can't drag around a
I've just read on a blog that the UDID will not survive iOS 5.
I am building an iOS game with OpenGL ES 2.0 that contains a scene
I need to create some plist files that will be read on an iOS

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.