OpenGL Pixel Format Attributes (NSOpenGLPixelFormatAttibutes) explanation?
- by nacho4d
Hi,
I am not new to OpenGL, but not an expert. Many tutorials teach how to draw, 3D, 2D, projections, orthogonal, etc, but How about setting a the view? (NSOpenGLView in Cocoa, Macs).
For example I have this:
- (id) initWithFrame: (NSRect) frame
{
GLuint attribs[] = { //PF: PixelAttibutes
NSOpenGLPFANoRecovery,
NSOpenGLPFAWindow,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAStencilSize, 8,
NSOpenGLPFAAccumSize, 0,
0
};
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs];
return self = [super initWithFrame:frame pixelFormat: [fmt autorelease]];
}
And I don't understand very well their usage, specially when combining them.
For example:
If I want my view to be capable of full screen should I write NSOpenGLPFAFullScreen only ? or both? (by capable I mean not always in full screen)
Regarding Double Buffer, what is this exactly? (Below: Apple's definition)
If present, this attribute indicates
that only double-buffered pixel
formats are considered. Otherwise,
only single-buffered pixel formats are
considered
Regarding Color: if NSOpenGLPFAColorSize is 24 and NSOpenGLPFAColorSize is 8 then it means that alpha and RGB components are treated differently? what happen if I set the former to 32 and the later to 0?
Etc, etc,In general how do I learn to set my view from scratch?
Thanks in advance.
Ignacio.