Re: PBuffer_Create and compatible pixel format
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com On Jun 24, 2010, at 7:30 PM, Steve Christensen wrote: CGLError error = kCGLNoError; Darrin -- Darrin Cardani dcardani@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.ap... I'm not sure if it's better to ask here or on the OpenGL list, so please point me there if this is off-topic. I'm using PBuffer_Create and friends in a plugin (included in EffectHelpers.m in the FxPlug samples). It works fine except on one of our test computers that contains multiple graphics cards and displays. For that case it fails with the stock code when calling CGLCreateContext. I've ended up modifying it as follows and now works on all of our computers. pbuffer->pixelFormat = CGLGetPixelFormat(sharedContext); if (pbuffer->pixelFormat == NULL) { // do the stock pixel format setup here //... error = CGLChoosePixelFormat(pixelFormatAttributes, &pbuffer-
pixelFormat, &numPixelFormats);
} if (error == kCGLNoError) { error = CGLCreateContext(pbuffer->pixelFormat, sharedContext, &pbuffer->pbufferContext); //... } The problem is that I need to add a couple of attributes to the pixel format. If I were to use the stock code, it'd be no problem: just add it to the list. However on our problem computer, the shared context's pixel format has two virtual screens, so I'm unsure how to get ahold of all of the attributes, add the new ones, and then create a new pixel format. Is this possible or am I going off in the wrong direction? Steve, I forwarded this on to someone else on our team who was more intimately familiar with this aspect of OpenGL, and here's what he said: In general, what he's trying to do is tough to get right. I ran into something similar (and I'm not convinced I got it right either). I'm only guessing about what he's doing from his description, but it sounds like he wants to -- get the CGLPixelFormatObj from an existing CGLContextObj -- use CGLDescribePixelFormat to get various attributes from an existing CGLPixelFormatObj -- tweak/add to those attributes -- then build a new CGLPixelFormatObj with the tweaked attributes -- which he then uses to try to create a new CGLContextObj that shares with the original CGLContextObj Two gotchas I ran into: 1) when there are multiple GPUs/virtual screens installed, the renderer ID that comes back from CGLDescribePixelFormat is essentially useless, so he should not specify this attribute (you never really need to anyway); and 2) he has to specify the kCGLPFAAllowOfflineRenderers attribute in the pixel format (if he's doing the above, he's probably already doing this because it would be one of the attributes that comes back from CGLDescribePixelFormat from our context, but just to be sure). Part of what makes this tough to get right is that there could be additional attributes that get added in the future that might be important that he wouldn't know to copy. Also, some attributes can't be tweaked like this; if he's changing pixel format (e.g., float vs. int) or asking for different buffers, it just may not be possible. Part of the feedback I got from one of the OpenGL engineers is that maybe rethinking the strategy might be more effective (e.g., using an FBO instead of a PBuffer). This email sent to site_archiver@lists.apple.com
participants (1)
-
Darrin Cardani