Results 1 to 7 of 7

Thread: Retaining drawn objects after app goes into background

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    4

    Retaining drawn objects after app goes into background

    Hi,

    I'm drawing a waveform programmatically by drawing vertical lines using
    glDrawArrays(GL_LINES, 0, noOfVertices);

    I've enabled kEAGLDrawablePropertyRetainedBacking on my GLKView and am getting the results I want.
    My waveform that is drawn programmatically is being retained and OpenGL ES doesn't need to redraw the prior waveform bits for every frame.
    However, I have an issue - when my app resigns (goes into background), and comes again to the foreground, the previous drawn OpenGL drawn objects are cleared. I actually see what I previously drew for a split second, and then it is cleared away.
    I commented out all the glClear commands in my code, but it doesn't help. The clearing on the app coming into foreground still happens.

    In my case, redrawing all the lines of the waveform is not really an option as it's resource intensive.

    How do I retain the backing even when my app resigns ? Many thanks for your help here.

  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: Retaining drawn objects after app goes into background

    OpenGL ES is not designed to be used this way. It might work sometimes, but this is going to be very dependent on the OpenGL ES and EGL drivers your app is running on.

    For example, most OpenGL ES GPUs (such as PowerVR and Adreno) are tile-based deferred renderers which rely upon the glClear call to know when to clear their internal buffers. Not doing the glClear call will produce unpredictable behavior.

    Also, OpenGL ES renderers do not really draw lines. They are rendered as degenerate triangles.

    Why do you even need a graphics API to just draw vertical lines?

    Regards, Clay

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    4

    Re: Retaining drawn objects after app goes into background

    I'm drawing a waveform that shows the recording input of my app in real time. Is there any tried and true way for doing this in OpenGL ES? Thanks for your reply.

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: Retaining drawn objects after app goes into background

    OpenGL does not know anything about waveforms.

    Maybe you need OpenGL to animate your graphics with some special effects? Otherwise, I would look at using a simpler 2D API that is native to iOS, or just draw the vertical line pixels directly into a bitmap with a loop.

    Regards, Clay

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    4

    Re: Retaining drawn objects after app goes into background

    Yes, I do need some animation on other aspects of my glkview, plus the wave input is being displayed in real time. My app is quite timing critical, and I read that opengl es will give me the best performance, hence I did it this way. So far, it has been ok except for this instance where glclear is somehow clearing my view when coming back from the background.

    I'm interested in your second suggestion, drawing vertical line pixels directly with a loop - how does that work? Is it opengl?

  6. #6
    Junior Member
    Join Date
    Feb 2013
    Posts
    4

    Re: Retaining drawn objects after app goes into background

    Just a thought, I'm able to render my waveform to a texture, and print it to the screen at every frame right? Is this a good practice to go about this instead of my enabling retain graphics way?

  7. #7
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: Retaining drawn objects after app goes into background

    You could save your texture image data to a file in an uncompressed RGB format, then redraw the entire waveform using it whenever the app is resumed.

    Regards, Clay

Similar Threads

  1. Using bitmaps as a background
    By lucafr in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 06-25-2008, 03:00 PM
  2. eglCreatePixmapSurface problem: the object is not drawn on t
    By Fadi Chehimi in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 01-12-2007, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •