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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:29:02+00:00 2026-06-13T23:29:02+00:00

When I launch my game I want the screen to show a loading image

  • 0

When I launch my game I want the screen to show a loading image while loading resources in the background. I do this by loading a simple UIImageView component and adding a “spinner” to it, to give the user feedback, that the device is loading something in the background.

While this image is showing I load all my images and textures and set up my OpenGL view and let it render.
When the 2nd frame gets rendered I want to hide the ImageView and only show the OpenGL view. I don’t want the OpenGL view to show on the first frame because it takes awfully long to render.

However, I have some problems with loading all my resources and setting up the DisplayLink for the OpenGL view to enter the render loop in a new thread and then showing the OpenGL view when loading is finished. The render loop doesn’t seem to start.

Here is the loadView method of my View Controller

- (void)loadView 
{
CGRect mainScreenFrame = [[UIScreen mainScreen] applicationFrame];

    // Set up the image view
    UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Startscreen" ofType:@"png"]];
    _imageView = [[UIImageView alloc] initWithFrame:mainScreenFrame];
    _imageView.image = img;

    // Set up the spinner
    _spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [_spinner setCenter:CGPointMake(mainScreenFrame.size.height/3.0*1.85, mainScreenFrame.size.width/10.0*7.55)];
    [_imageView addSubview:_spinner];    
    [_spinner startAnimating];

    // Show the loading image
    self.view = _imageView;

    /* Load resources in a new thread -- this shows the spinner during loading */
    [NSThread detachNewThreadSelector:@selector(loadGLView) toTarget:self withObject:nil];
}

loadGLView only does the following and initializes the OpenGL View and starts the loading process.

_glView = [[JungleOpenGLView alloc] initWithFrame:mainScreenFrame];

This is how I set up the DisplayLink in the OpenGL View.

CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(setupRender:)];
[displayLink setFrameInterval:2];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];

When the 2nd frame gets rendered I send a notification and the ViewController then sets

self.view = _glView;
  • 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-06-13T23:29:03+00:00Added an answer on June 13, 2026 at 11:29 pm

    I found my mistake.
    Instead of creating a new thread for the loading method like this:

    [NSThread detachNewThreadSelector:@selector(loadGLView) toTarget:self withObject:nil];
    

    I used:

    [self performSelectorInBackground:@selector(loadGLView) withObject:nil];
    

    That does the trick. Good read on this subject (creating threads) can be found here: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html

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

Sidebar

Related Questions

I want my program to be able to launch any Windows game, and while
I'm making my first D3D simple game. My game uses many images. This is
For the option to launch a new EC2 instance like this one, how similar
I'm using LibGdx to develop a Java-based game. I haven't decided whether I want
I'm working on this game titled Fortress, located at http://www.joemajewski.com/fortress . Anyways, it's one
I made a simple game for the iPhone using OpenGL ES. Everything works fine
I would like to do the following: Sell a game for $0.99 at launch
If I launch a window with a flash game in it, and Chrome's popup
So I am working on a simple android Tetris type game. On the first
Our application launches ListActivity that displays two menu options with launch a football game

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.