Assignment 8 — Redrawing the View

I’ve had several people email me with issues redrawing the board on touch events. Since this seems to be a semi-common problem, I thought I’d take a moment to address it here.

The problem is likely caused by not all of the draw code being executed. If you take a look at the GLView class’s drawView method, you’ll see that there’s some code before and after the call to the delegate’s (the view controller) drawView: method. It is this code that actually does the screen refresh.

- (void)drawView {
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
  [delegate drawView:self];
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
  [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

So, by simply calling the view controller’s drawView: method the screen refresh doesn’t happen. To ensure this code gets called, instead of invoking the view controller’s drawRect: method simply invoke the GLView’s (the view controllers view property) drawRect method like so…

[(GLView *)self.view drawView];
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: