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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:31:41+00:00 2026-05-15T22:31:41+00:00

I’ve got a lovely OpenGLES code slice that renders up images for me. When

  • 0

I’ve got a lovely OpenGLES code slice that renders up images for me. When I want to, I can call a function on it:

-(UIImage *)renderToImage;

That does a lot of rendering work and returns me an image. This includes the generation of FBOs, textures, etc.

Lately, I’ve found myself needing to enhance this. The image generation takes four seconds, so I want to pass off the work to another thread and let the app continue. This seemed simple enough. I made a method with this code:

-(void) generateRandomNewImage:(MyViewController *)evc{
UIImage * renderedImage = [self renderToImage];
NSString * fileLoc = [self writeToTempFile:renderedImage];
NSLog(@"File location:%@",fileLoc);
[evc performSelectorOnMainThread:@selector(imageGenerationComplete:) withObject:fileLoc waitUntilDone:NO];
}

Hopefully you can see the logic going on here. This method renders the image, saves it to the filesystem, and calls a method on the main thread’s viewcontroller to let it know the file is ready. This code is inside my opengl renderer. It’s called here, in the main thread’s viewcontroller:

thread = [[NSThread alloc] initWithTarget:renderer 
                           selector:@selector(generateRandomNewImage:) 
                           object:self];
[thread start];

To me, that seems fine too. When I run this code, I get told in my console that my framebuffer object status were error’ed, with a status of zero. I have no idea why. As a result, I get a blank image (saving to the temp files work, by the way, I’ve tested them).

To test, I put all of this code into the main thread, didn’t create any new threads or anything. It all worked fine. As soon as I try and pass off the image generation to another thread, I hit problems.

  • 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-15T22:31:42+00:00Added an answer on May 15, 2026 at 10:31 pm

    Using OpenGL in another thread is not that simple as that, only one thread can use a OpenGL context at a time, and your second thread doesn’t have a OpenGL context, thus all OpenGL calls fail.

    Solution: Create another OpenGL context for the second thread, and read this.

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

Sidebar

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.