views:

202

answers:

1

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.

+1  A: 

Regarding color, I'm not entirely sure the difference.

Regarding double buffering: Let's say you have a slow frame rate, 3fps. If it takes a third of a second to draw everything on the screen, you're going to see them as they draw. If it's drawn using the painter's algorithm for instance, you'll see the background polygons first, then you'll see things closer up. Also, the last thing to get drawn would only be on for an instant before it gets cleared to draw the next frame.

Double buffering renders everything to an offscreen image, then puts the entire rendered image on the screen. So you won't see any action until you've rendered the whole thing, but you won't see an incomplete frame either.

For more, http://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics

glowcoder