• 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
trying to get the NSOpenGLContext of my second screen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trying to get the NSOpenGLContext of my second screen


  • Subject: trying to get the NSOpenGLContext of my second screen
  • From: "Giovanni Donelli" <email@hidden>
  • Date: Wed, 29 Aug 2007 16:03:08 +0200

Hello Cocoa Gurus,
   I hope there are some OpenGL masters among you.


I found on the ADC some sample code for taking snapshot of your main screen:

http://developer.apple.com/samplecode/OpenGLScreenSnapshot/index.html


Pretty cool stuff, it uses OpenGL to grab each screen pixels super fast.


What I am trying to do now is to modify its code so that is able to take the
screenshot of an arbitrary display, not only the main screen but also my
secondary screen.

...and here I have a problem... I am not able to figure out how to get the
 NSOpenGLContext of my second display
The problem, I think, is that I am not really able to get a proper
NSOpenGLPixelFormat
to init with a give display... any suggestions????

this is the code:

+(NSOpenGLContext
*)fullScreenGLGraphicsContextForDisplay:(CGDirectDisplayID)displayID

{

    CGOpenGLDisplayMask  openGLDisplayMask = CGDisplayIDToOpenGLDisplayMask(
displayID);

     // Specify attributes of the GL graphics context

    NSOpenGLPixelFormatAttribute attributes[] = {

            NSOpenGLPFAFullScreen, YES,

            NSOpenGLPFAScreenMask, openGLDisplayMask,

            (NSOpenGLPixelFormatAttribute) 0

    };


    NSOpenGLPixelFormat *glPixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:attributes];

    if (!glPixelFormat)

    {

NSLog(@"%s glPixelFormat impossible to get pixel format", __FUNCTION__);

        return nil;

    }


    // Create OpenGL context used to render

    NSOpenGLContext *glContext = [[[NSOpenGLContext alloc]
initWithFormat:glPixelFormat shareContext:nil] autorelease];


    // Cleanup, pixel format object no longer needed

    [glPixelFormat release];



    return glContext;

}



Thank you!


Giovanni
_______________________________________________

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

  • Prev by Date: Re: NSXMLDocument freezes UI
  • Next by Date: Re: encoding vended objects
  • Previous by thread: radio buttons in NSMatrix obscuring text field
  • Next by thread: Validating NSXMLDocument with DTD that has ANY condition
  • Index(es):
    • Date
    • Thread