geminiCoder
geminiCoder

Reputation: 2906

Where is this method called - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect

Im just starting to look at Open GL ES for iOS and I'm looking through the source code on apples template code. The problem is both

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect

and

- (void)update

are being called, but I'm unable to determine by what and how to change the frequency?

Upvotes: 3

Views: 1721

Answers (1)

Praxiteles
Praxiteles

Reputation: 6010

glkView is called automatically when the view needs to be updated.

According to Apple "A GLKView object uses the regular view drawing cycle for a UIView object, calling its drawRect: method whenever the contents of the view need to be updated."

You can use a GLKViewController to set the framerate of the glkview like this:

- (void)viewDidLoad
{
     self.preferredFramesPerSecond = 60;
}

Update is also called automatically for you before the rendering. You can use this call to update variables such as the locations of your drawn objects - but you may want to use the timeSinceLastUpdate property because the time elapsed between calls can vary.

Upvotes: 3

Related Questions