OpenGL Pixel Format Attributes (NSOpenGLPixelFormatAttibutes) explanation?
Posted
by nacho4d
on Stack Overflow
See other posts from Stack Overflow
or by nacho4d
Published on 2010-05-06T15:16:29Z
Indexed on
2010/05/06
15:18 UTC
Read the original article
Hit count: 192
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.
© Stack Overflow or respective owner