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

The Archive Base Latest Questions

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

I have a EAGLView that I wish to convert into a UIImage. I can

  • 0

I have a EAGLView that I wish to convert into a UIImage. I can do this with the solution posted here:

How to get UIImage from EAGLView?

However, I can only accomplish this if a small amount of time has gone by between the creation of the EAGLView and the UIImage.

This code, which creates a EAGLView, and then a UIImageView right afterwards, does not work:

EAGLView *EAGLphoto = [[EAGLView alloc] initWithImage:photo.workAreaImage];

[theWorkArea.photoArea1 addSubview:EAGLphoto];

//I put a glfinish() here but it didn't help

UIImageView *photoView = [[UIImageView alloc] initWithImage:[self glToUIImage]];
//glToUIImage is taken from the link above

[theWorkArea.photoArea2 addSubview:photoView];

I’m assuming the UIImageView tries to get created before the EAGLView is finished being created. I tried to put a glfinish() in between but it did nothing. When I run the code, the EAGLView shows up fine but the UIImageView shows up as black.

However, this modified version of the above code works:

EAGLView *EAGLphoto = [[EAGLView alloc] initWithImage:photo.workAreaImage];

[theWorkArea.photoArea1 addSubview:EAGLphoto];

[self performSelector:@selector(getUIImage) withObject:nil afterDelay:0.1];

- (void)getUIImage {

    UIImageView *photoView = [[UIImageView alloc] initWithImage:[self glToUIImage]];
    //glToUIImage is taken from the link above

    [theWorkArea.photoArea2 addSubview:photoView];

}

Am I using glfinish() incorrectly? Is there a better method than my hack?

  • 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-24T22:36:20+00:00Added an answer on May 24, 2026 at 10:36 pm

    Usually when you make visible changes to UIKit objects instead of updating instantly they merely flag themselves to make those changes in the future, then do the whole set of changes as a batch next time you relinquish the main thread (by returning to the runloop). That’s not a misfeature or a failure in the implementation, it’s actually usually what you implicitly expect, being the reason you can write code like:

    view.frame = someNewFrame;
    view.someOtherProperty = someOtherValue;
    

    And not worry that every so often the view will visibly adopt the new frame before adopting the other changes. As a rule, you want the things you do to views to appear to be atomic.

    Occasionally you run into a situation, as you have here, where the fact that changes you’ve already requested haven’t come into effect yet is exposed. frame and someOtherProperty would return their new values in the above example so that you don’t care whether the changes took effect immediately or not, but based on your observation about performSelector:withObject:afterDelay: it seems likely that you’ve stumbled upon a situation where the change doesn’t pretend to be immediate.

    EAGLView is difficult to diagnose because it’s not really a UIKit feature. The CAEAGLLayer that it’s built upon is, but EAGLView is just the name Apple have adopted for a custom UIView subclass built on CAEAGLLayer in various example projects. They’ve not been consistent about the interface or implementation of EAGLView across their examples, but at a guess I’d say that probably it’s creating the OpenGL frame buffer object (that is, the thing that OpenGL uses to store numbers related to pixels, allowing glReadPixels to work) only when asked to lay itself out, and it doesn’t lay itself out until UIKit asks it to do so. Which isn’t until you’ve dropped out to the runloop.

    That diagnosis can be confirmed by checking the code of the EAGLView that you have. If there are a bunch of calls to things like glGenFramebuffers that are triggered as a result of layoutSubviews, drawRect or some other method that isn’t called directly by the relevant init then that proves it.

    Assuming that diagnosis to be correct, you could adapt EAGLView but I think probably the best solution is just to stick to performSelector:withObject:afterDelay:0. This isn’t a race condition, so that solution isn’t in the slightest bit flakey or unreliable, it’s just a slightly roundabout way of saying “let UIKit catch up with all of those instructions, given that I know that’ll let EAGLView get into a meaningful state, then continue with my stuff”.

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

Sidebar

Related Questions

I have an EAGLView (taken from Apple's examples) which I can successfully convert to
I have a UIImage. I have an EAGLView in my app, which is a
I have some memory which is initialized in initWithCoder:. I can verify that before
Have some dates in my local Oracle 11g database that are in this format:
Have an app that can use tts to read text messages. It can also
Have just started to get into CakePHP since a couple of weeks back. I
Have such a problem, hope you'll help me.. Can't find anywhere. Here is the
A simplified example here: I have a game that I am writing in opengl
I have a Cocos2d game scene that loads with an EAGLView loaded by a
I have a 3D project based on the EAGLView exemple from Apple. I have

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.