Skip to content

Instantly share code, notes, and snippets.

@ryanwilliams
Created March 18, 2010 01:20
Show Gist options
  • Save ryanwilliams/335941 to your computer and use it in GitHub Desktop.
Save ryanwilliams/335941 to your computer and use it in GitHub Desktop.
glEnable(GL_SCISSOR_TEST);
// Some region to clip to
CGRect rect = CGRect(100, 100, 200, 200);
CGRect frame = [[[CCDirector sharedDirector] openGLView] frame];
// Adjust for position
CGPoint worldPos = [self convertToWorldSpaceAR:position_];
rect.origin.x = frame.size.height - worldPos.x - rect.origin.x - rect.size.width;
rect.origin.y += worldPos.y;
CGPoint origin = [[CCDirector sharedDirector] convertToGL:rect.origin];
glScissor(origin.x, origin.y, rect.size.height, rect.size.width);
glDisable(GL_SCISSOR_TEST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment