Re: PBuffer_Create and compatible pixel format
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com On Jun 28, 2010, at 9:08 AM, Darrin Cardani wrote: On Jun 24, 2010, at 7:30 PM, Steve Christensen wrote: CGLError error = kCGLNoError; Thanks for helping to dig up more detailed information. steve _______________________________________________ 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). Yes, he's right about what we're trying to do. For the simple case that PBuffer_Create supports, I'd just add the attributes to the array and be done with it. The problem we ran into was when we were runnning on a computer with multiple virtual screens, when the context creation failed. My original question was prompted because I ran into a roadblock where I couldn't figure out how to set up the pixel format attributes to specify multiple virtual screens; you can read them back after the fact, but I couldn't figure out how to set it up in the first place... This email sent to site_archiver@lists.apple.com
participants (1)
-
Steve Christensen