• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: opengl rendering outside of -drawRect:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: opengl rendering outside of -drawRect:


  • Subject: Re: opengl rendering outside of -drawRect:
  • From: Richard Charles <email@hidden>
  • Date: Sat, 18 Jun 2016 11:04:38 -0600

> On Jun 11, 2016, at 7:43 AM, Richard Charles <email@hidden> wrote:
>
> Before calling drawRect:, the system locks focus on the view. Each view has its own graphic context. When the focus is locked on a view, the view’s graphics context is active. When the focus is unlocked, the graphics context is no longer active. Drawing commands are always executed in the current graphic context.

> On Jun 16, 2016, at 6:19 PM, James Walker <email@hidden> wrote:
>
> I doubt that it is necessary to lock focus on the view, because you are not really drawing in the view or even in the window.  You are drawing in a separate "surface" that is normally in a layer above the window. See NSOpenGLCPSurfaceOrder.

A typical implementation of lockFocus for use with OpenGL might look like this.

- (void)lockFocus
{
    NSOpenGLContext* context = [self openGLContext];
    if ([context view] != self) {
        [context setView:self];
    }
    [context makeCurrentContext];
}

If you have only one OpenGL context in your app and it is the current context for the view then you do not need to lock focus. So I think the takeaway is that draw calls operate within a graphic context. If the context you want and need is the current context then you are good to go.

I suppose it might be different if you are drawing full screen rather than into a window or view. Drawing full screen your app could still have multiple graphic contexts. If your full screen app has only one graphic context then you are good to go.

I am no expert in OpenGL or Cocoa but I think this is the way it works.

--Richard Charles


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: opengl rendering outside of -drawRect:
      • From: Richard Charles <email@hidden>
  • Prev by Date: Re: Swift 3 - Notification leaks
  • Next by Date: Re: opengl rendering outside of -drawRect:
  • Previous by thread: Re: opengl rendering outside of -drawRect:
  • Next by thread: Re: opengl rendering outside of -drawRect:
  • Index(es):
    • Date
    • Thread