Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Columbo X

macrumors member
Original poster
Jun 10, 2007
62
0
UK
I'm currently porting a library of effects (depth of field, glow, HDR etc.) from Windows to Mac OS and am looking to create floating point framebuffers in Cocoa. The documentation seems straightforward and I've setup and validated a hardware accelerated pixel format as follows...

// ID of main display - running MBP mid-late 07 with 8600M GT GPU with Leopard 5.5
CGDirectDisplayID display = CGMainDisplayID();

GLuint attributes[] =
{
NSOpenGLPFAScreenMask, (NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
NSOpenGLPFAWindow,
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorFloat,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)64,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
NSOpenGLPFAMinimumPolicy,
0
};

NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*)attributes];

if (fmt) {

printf("pixel format VALID!\n");

// check details of returned pixel format
GLint noofVirtualScreens = [fmt numberOfVirtualScreens];

GLint colourFloatBuffer, colourSize, alphaSize;
[fmt getValues:&colourFloatBuffer forAttribute:NSOpenGLPFAColorFloat forVirtualScreen:0];
[fmt getValues:&colourSize forAttribute:NSOpenGLPFAColorSize forVirtualScreen:0];
[fmt getValues:&alphaSize forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:0];

printf("number of virtual screens = %d\n", noofVirtualScreens);
printf("Colour Buffer = %d\n", colourFloatBuffer); // 1=okay
printf("colour size = %d\n", colourSize);
printf("alpha size = %d\n", alphaSize);

}
else
{
printf("pixel format not valid!\n");
}


I seem to get a valid pixel format with a 64 bit colour buffer setup okay. However, on rendering into a subclass of NSView I get nothing at all - just a white b/ground as if the context is not bound to the view. If I remove the NSOpenGLPFAColorFloat flag and set the colour size to 32 I get output as normal.

Has anyone else tried using floating point buffers on the 8600M and run into similar problems? I'm wondering if there are properies of the NSView that need to be changed?

Thanks in advance.

C
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
If you're using Cocoa, shouldn't you be rendering into an NSOpenGLView? And using NSOpenGLPixelBuffer and NSOpenGLContext?
 

Columbo X

macrumors member
Original poster
Jun 10, 2007
62
0
UK
Yes, I've tried sub-classing NSOpenGLView and setting the pixel format properties in Interface Builder. But I get the same behaviour. My sub-class of NSView (based on Apple's examples of setting up your own OpenGL view) has essentially the same functionality of NSOpenGLView and maintains it's own NSOpenGLPixelFormat and NSOpenGLContext.
 

Columbo X

macrumors member
Original poster
Jun 10, 2007
62
0
UK
Hi lazydog,

I also tried this - I ran one of the OpenGL demos from Apple and it worked fine until I added the NSOpenGLPFAColorFloat attributes to the initWithFrame: method - after which nothing gets rendered.

Do you have an nVidia GPU in your iMac? I'll have to test this on our iMacs at work to see if I get more luck.

Thanks,

C
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi Columbo

I think it's an ati chipset. Have you looked at the supported formats? You can do this using the Open GL Driver Monitor app in the developers directory. For example, on my Powerbook 64 and 128 bit float argb is supported.

b e n
 

Columbo X

macrumors member
Original poster
Jun 10, 2007
62
0
UK
Have you looked at the supported formats?

Yeah, I checked this just now - the 64 and 128 bit floating point formats are supported in hardware. I'll try this out on our ATI-based iMacs tomorrow.

---

Update: The code worked fine on an ATI 2600 iMac - time for a bug report to Apple I think.

Cheers,
C
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.