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

  • Home
  • SEARCH
  • 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 651691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:11:24+00:00 2026-05-13T22:11:24+00:00

I have a simple iPhone application which uses OpenGL ES (v1) to draw a

  • 0

I have a simple iPhone application which uses OpenGL ES (v1) to draw a line based on the touches of the user. In the XCode Simulator, the code works perfectly. However, when I install the app onto an iPod or iPhone, the OpenGL ES view “flashes” when drawing the line. If I disable the line drawing, the flash disappears. By “flash”, I mean that the background image (which is an OpenGL texture) disappears momentarily, and then reappears. It appears as if the entire scene is completely erased and redrawn.

The code which handles the line drawing is the following:

renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end
{
    static GLfloat*       vertexBuffer = NULL;
    static NSUInteger vertexMax = 64;
    NSUInteger            vertexCount = 0,
    count,
    i;

    //Allocate vertex array buffer
    if(vertexBuffer == NULL)
        vertexBuffer = malloc(vertexMax * 2 * sizeof(GLfloat));

    //Add points to the buffer so there are drawing points every X pixels
    count = MAX(ceilf(sqrtf((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)) / kBrushPixelStep), 1);
    for(i = 0; i < count; ++i) {
        if(vertexCount == vertexMax) {
            vertexMax = 2 * vertexMax;
            vertexBuffer = realloc(vertexBuffer, vertexMax * 2 * sizeof(GLfloat));
        }

        vertexBuffer[2 * vertexCount + 0] = start.x + (end.x - start.x) * ((GLfloat)i / (GLfloat)count);
        vertexBuffer[2 * vertexCount + 1] = start.y + (end.y - start.y) * ((GLfloat)i / (GLfloat)count);
        vertexCount += 1;
    }

    //Render the vertex array
    glVertexPointer(2, GL_FLOAT, 0, vertexBuffer);
    glDrawArrays(GL_POINTS, 0, vertexCount);

    //Display the buffer
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

(This function is based on the function of the same name from the GLPaint sample application.)
For the life of me, I can not figure out why this causes the screen to flash. The line is drawn properly (both in the Simulator and in the iPod). But, the flash makes it unusable.

Anyone have ideas on how to prevent the “flash”?

  • 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-13T22:11:25+00:00Added an answer on May 13, 2026 at 10:11 pm

    After much testing, I have found a solution to this issue, although I’m not sure if it’s a best-practice.

    The solution was changing the kEAGLDrawablePropertyRetainedBacking from NO to YES. This stopped the flashing. Specifically, the code to setup the OpenGL view now looks like this:

    CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
    eaglLayer.opaque = YES;
    eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithBool:YES], 
                                    kEAGLDrawablePropertyRetainedBacking, 
                                    kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil];
    

    Again, I’m not sure if it’s a best practice to use the RetainedBacking strategy, but it stopped the flashing. According to http://developer.apple.com/iphone/library/documentation/iPhone/Reference/EAGLDrawable_Ref/EAGLDrawable/EAGLDrawable.html#jumpTo_6 one should set RetainedBacking to YES only in certain circumstances.

    Setting the value to YES is recommended only when you need the content to remain unchanged, as using it can result in both reduced performance and additional memory usage.

    It’s not clear how the performance or memory is impacted, but this one change completely stopped all “flashing” that I was seeing.

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

Sidebar

Related Questions

I have developed a simple location aware iPhone application which is functionally working very
My i have to develop simple window based iphone application. In my first screen
I have a very simple scenario: My iPhone application contains a UIViewController implementation which
I have a reasonably simple split view application adapted from iPhone code. The main
I have a simple iPhone application that is very similar to the Page Control
I have a fairly simple iPhone application that I want to have run on
I have written a tab based iPad application which has done well. I never
I'm currently writing an iPhone application which gets some data from the user and
I have an application, which uses some 3rd party libraries, for example Tesseract library.
In my iPhone app, I have a (non-grouped) UITableView which uses all the bells

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.