Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pbuffers + Cg + Glut




I had similar problems using the combination of floating point pbuffers, Cg and GLUT.
Depending upon your particular problem, this may or may not be of any help.

In my case, I was either getting invalid pixel format or invalid share context, when trying to create
a floating point PBuffer.

Although I haven't managed to solve this problem using GLUT, I have had moderate success using a Cocoa
Frontend.

This link was quite helpful with regards context sharing http://developer.apple.com/qa/qa2001/qa1248.html

I have a basic C++ Libary which my app links with. My PBuffer creation code is like this:-

CGLPixelFormatAttribute attrib[]={
kCGLPFADisplayMask, (CGLPixelFormatAttribute)(0),
// kCGLPFAPBuffer,
kCGLPFANoRecovery,
kCGLPFAAccelerated,
kCGLPFAColorFloat,

kCGLPFAColorSize,(CGLPixelFormatAttribute)(64),
kCGLPFADepthSize,(CGLPixelFormatAttribute)(24),
(CGLPixelFormatAttribute)0};


CGDirectDisplayID display = CGMainDisplayID();
attrib[1] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display);


long npix;
CGLPixelFormatObj pixFmt;
err = CGLChoosePixelFormat(attrib, &pixFmt, &npix);
DisplayCGLError(err);


m_windowContext = CGLGetCurrentContext();
long swapInterval = 1;
err = CGLCreateContext(pixFmt, m_windowContext, &m_context);
DisplayCGLError(err);


err = CGLCreatePBuffer(m_width, m_height, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA, 0, &m_pbuffer);
DisplayCGLError(err);


err = CGLGetVirtualScreen(m_windowContext, &m_vscreen);
DisplayCGLError(err);

The important bit (I think) for getting shared contexts is this.

kCGLPFADisplayMask, (CGLPixelFormatAttribute)(0),

CGDirectDisplayID display = CGMainDisplayID();
attrib[1] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display);

Now when I call this from GLUT using whatever pixel format it sets up, I get a invalid share context error.
However if I use Cocoa where I have control over the OpenGL Pixel Format for my OpenGLView class

NSOpenGLPixelFormatAttribute attrs[] =
{
NSOpenGLPFAScreenMask, 0,
NSOpenGLPFANoRecovery,
NSOpenGLPFAColorSize, 32,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFADoubleBuffer, nil
};


displayID = CGMainDisplayID();
attrs[1] = (NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(displayID);
pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attrs];
[self setPixelFormat: pixFmt];
[pixFmt release];

When I create a floating point PBuffer now, using exactly the same code, my invalid share context error's
go away.

Unfortuanatly that is the limit to my success with this on OSX, I'm no longer getting error's so it seems the
PBuffers are setup correctly, however, I'm not getting the results I expect, and haven't had the time to delve into this
any further.

With regards GLUT, the problem seems to be down to creating shared contexts for the main window and pbuffers,
there may be a way around this, but I have no idea what it may be.

Hope this helps

Claire

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden

References: 
 >pbuffers + Cg + Glut (From: Gordon Erlebacher <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.