Back to index

libsfml  1.6+dfsg2
Public Member Functions | Static Public Member Functions
sfPrivGLContext Class Reference

Window independant OpenGL context class /////////////////////////////////////////////////////////. More...

#import <GLKit.h>

List of all members.

Public Member Functions

(id) - initWithAttributes:mode:sharedContext:
 Make a new OpenGL context according to the settings and the shared context /////////////////////////////////////////////////////////.
(void) - dealloc [implementation]

Static Public Member Functions

(id) + sharedContext
 Return the shared OpenGL context instance (making one if needed) /////////////////////////////////////////////////////////.

Detailed Description

Window independant OpenGL context class /////////////////////////////////////////////////////////.

Definition at line 35 of file GLKit.h.

Member Function Documentation

- (void) dealloc [implementation]

Definition at line 85 of file

       [[sfPrivGLContext sharedContext] release];
       [super dealloc];

Here is the call graph for this function:

- (id) initWithAttributes: (sf::WindowSettings&)  attribs
mode: (const sf::VideoMode&)  mode
sharedContext: (sfPrivGLContext *)  context 

Make a new OpenGL context according to the settings and the shared context /////////////////////////////////////////////////////////.

Definition at line 95 of file

                        :(sf::WindowSettings&)attribs mode:(const sf::VideoMode&)mode sharedContext:(sfPrivGLContext *)sharedContext
       // Note about antialiasing and other context attributes :
       // OpenGL context sharing does not allow the shared contexts to use different attributes.
       // The point is that the default shared global OpenGL context uses default parameters.
       // That means that all the other context *should* use the same paramaters.
       // Fortunately some values parameters for some parameters are compatible, but some are not
       // among which : the antialising level.
       // I've no way to fix this for now.
       if (attribs.AntialiasingLevel) {
              NSLog(@"Warning: antialiasing settings are inhibited on Mac OS X for technical reasons");
       if (attribs.StencilBits != 8) {
              NSLog(@"Warning: stencil bits settings are inhibited on Mac OS X for technical reasons");
       NSOpenGLPixelFormat *myPixelFormat = nil;
       unsigned idx = 0;
       // Attributes list
       NSOpenGLPixelFormatAttribute ctxtAttribs[15] = {(NSOpenGLPixelFormatAttribute) 0};
       // Accelerated, double buffered
       ctxtAttribs[idx++] = NSOpenGLPFAClosestPolicy;
       ctxtAttribs[idx++] = NSOpenGLPFADoubleBuffer;
       ctxtAttribs[idx++] = NSOpenGLPFAAccelerated;
       // Force use of first screen
       //ctxtAttribs[idx++] = NSOpenGLPFAScreenMask;
       //ctxtAttribs[idx++] = CGDisplayIDToOpenGLDisplayMask([sfPrivAppController primaryScreen]);
       // windowed context (even fullscreen mode uses a window)
       ctxtAttribs[idx++] = NSOpenGLPFAWindow;
       // Color buffer bits ; usually 32 bits per pixel
       ctxtAttribs[idx++] = NSOpenGLPFAColorSize;
       // well.. whatever I put here, the color size is always 24 bits on my computer..
       ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) mode.BitsPerPixel;
       // Alpha buffer size
       // FIXME: I don't really remember whether I can safely use the user video mode settings
       // to set this attribute (because of the shared context attributes conflicts)
       if (mode.BitsPerPixel > 24) {
              ctxtAttribs[idx++] = NSOpenGLPFAAlphaSize;
              ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) 8;
       // Depth buffer size
       ctxtAttribs[idx++] = NSOpenGLPFADepthSize;
       ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) attribs.DepthBits;
       // Stencil buffer bits
       // Note: even with "NSOpenGLPFAClosestPolicy" set, the NSOpenGLPFAStencilSize value must be an valid and exact one
       // I've been looking for possible diffferent default stencil bits values among different Apple computers
       // but I can't again get the website I found oneaday
       // (describing all the graphic cards used by Apple, the supported extensions, etc).
       ctxtAttribs[idx++] = NSOpenGLPFAStencilSize;
       ctxtAttribs[idx++] = (NSOpenGLPixelFormatAttribute) /* attribs.StencilBits */ 8;
       myPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:ctxtAttribs];
       if (myPixelFormat) {
              self = [super initWithFormat:myPixelFormat
                                          shareContext:[sharedContext retain]];
              // Get the effective properties from our OpenGL context
              GLint tmpDepthSize = 0, tmpStencilBits = 0, tmpAntialiasingLevel = 0;
              if (self) {
                     [myPixelFormat getValues:&tmpDepthSize
                            forVirtualScreen:[self currentVirtualScreen]];
                     [myPixelFormat getValues:&tmpStencilBits
                            forVirtualScreen:[self currentVirtualScreen]];
                     [myPixelFormat getValues:&tmpAntialiasingLevel
                            forVirtualScreen:[self currentVirtualScreen]];
              attribs.DepthBits = (unsigned) tmpDepthSize;
              attribs.StencilBits = (unsigned) tmpStencilBits;
              attribs.AntialiasingLevel = (unsigned) tmpAntialiasingLevel;
              [myPixelFormat release];
       } else {
              NSLog(@"NSOpenGLPixelFormat creation failed! (invalid video settings ?)");
       return self;
+ (id) sharedContext

Return the shared OpenGL context instance (making one if needed) /////////////////////////////////////////////////////////.

Definition at line 74 of file

       // Make a new context with the default parameters
       sf::WindowSettings params;
       sf::VideoMode m;
       static sfPrivGLContext *sharedCtx = [[sfPrivGLContext alloc] initWithAttributes:params
       return sharedCtx;

Here is the caller graph for this function:

The documentation for this class was generated from the following files: