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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:02:52+00:00 2026-05-26T20:02:52+00:00

I’m currently developping an iPad app which is using OpenGL to draw some very

  • 0

I’m currently developping an iPad app which is using OpenGL to draw some very simple (no more than 1000 or 2000 vertices) rotating models in multiple OpenGL views.
There are currently 6 view in a grid, each one running its own display link to update the drawing. Due to the simplicity of the models, it’s by far the simplest method to do it, I don’t have the time to code a full OpenGL interface.

Currently, it’s doing well performance-wise, but there are some annoying glitches. The first 3 OpenGL views display without problems, and the last 3 only display a few triangles (while still retaining the ability to rotate the model). Also there are some cases where the glDrawArrays call is going straight into EXC_BAD_ACCESS (especially on the simulator), which tell me there is something wrong with the buffers.

What I checked (as well as double- and triple-checked) is :

  • Buffer allocation seems OK
  • All resources are freed on dealloc
  • The instruments show some warnings, but nothing that seems related

I’m thinking it’s probably related to my having multiple views drawing at the same time, so is there any known thing I should have done there? Each view has its own context, but perhaps I’m doing something wrong with that…

Also, I just noticed that in the simulator, the afflicted views are flickering between the right drawing with all the vertices and the wrong drawing with only a few.

Anyway, if you have any ideas, thanks for sharing!

  • 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-26T20:02:53+00:00Added an answer on May 26, 2026 at 8:02 pm

    Okay, I’m going to answer my own question since I finally found what was going on. It was a small missing line that was causing all those problems.

    Basically, to have multiple OpenGL views displayed at the same time, you need :

    • Either, the same context for every view. Here, you have to take care not to draw with multiple threads at the same time (i.e. lock the context somehow, as explained on this answer. And you have to re-bind the frame- and render-buffers every time on each frame.
    • Or, you can use different contexts for each view. Then, you have to re-set the context on each frame, because other display links, could (and would, as in my case) cause your OpenGL calls to use the wrong data. Also, there is no need for re-binding frame- and render-buffers since your context is preserved.

    Also, call glFlush() after each frame, to tell the GPU to finish rendering each frame fully.

    In my case (the second one), the code for rendering each frame (in iOS) looks like :

    - (void) drawFrame:(CADisplayLink*)displayLink {
      // Set current context, assuming _context
      // is the class ivar for the OpenGL Context
      [EAGLContext setCurrentContext:_context]
    
      // Clear whatever you want
      glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    
      // Do matrix stuff
      ...
      glUniformMatrix4fv (...);
    
      // Set your viewport
      glViewport (0, 0, self.frame.size.width, self.frame.size.height);
    
      // Bind object buffers
      glBindBuffer (GL_ARRAY_BUFFER, _vertexBuffer);
      glVertexAttribPointer (_glVertexPositionSlot, 3, ...);
    
      // Draw elements
      glDrawArrays (GL_TRIANGLES, 0, _currentVertexCount);
    
      // Discard unneeded depth buffer
      const GLenum discard[] = {GL_DEPTH_ATTACHMENT};
      glDiscardFramebufferEXT (GL_FRAMEBUFFER, 1, discard);
    
      // Present render buffer
      [_context presentRenderbuffer:GL_RENDERBUFFER];
    
      // Unbind and flush
      glBindBuffer (GL_ARRAY_BUFFER, 0);
      glFlush();
    }
    

    EDIT

    I’m going to edit this answer, since I found out that running multiple CADisplayLinks could cause some issues. You have to make sure to set the frameInterval property of your CADisplayLink instance to something other than 0 or 1. Else, the run loop will only have time to call the first render method, and then it’ll call it again, and again. In my case, that was why only one object was moving. Now, it’s set to 3 or 4 frames, and the run loop has time to call all the render methods.

    This applies only to the application running on the device. The simulator, being very fast, doesn’t care about such things.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.