Back to index

libsfml  1.6+dfsg2
Public Member Functions | Protected Attributes
sfPrivGLView Class Reference

Customized Cocoa OpenGL view /////////////////////////////////////////////////////////. More...

#import <GLKit.h>

Collaboration diagram for sfPrivGLView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(id) - initWithFrame:mode:settings:
 Make a new view according the the rect , the video mode , the window settings must not be null /////////////////////////////////////////////////////////.
(void) - setDelegate:
 Sets as the view delegate /////////////////////////////////////////////////////////.
(sf::priv::WindowImplCocoa *) - delegate
 Returns the view delegate /////////////////////////////////////////////////////////.
(void) - finishInitialization
 Finish view setting (after having added it to the window) /////////////////////////////////////////////////////////.
(void) - enableVerticalSync:
 Forward call to en/disable vertical synchronization /////////////////////////////////////////////////////////.
(void) - setActive:
 Forward call to set the OpenGL context as active according to /////////////////////////////////////////////////////////.
(void) - flushBuffer
 Forward call to flush the OpenGL context /////////////////////////////////////////////////////////.
(void) - dealloc [implementation]
 Clean the instance /////////////////////////////////////////////////////////.
(void) - pushEvent: [implementation]
 Send event to the linked window /////////////////////////////////////////////////////////.
(void) - viewFrameDidChange: [implementation]
 Notification method receiver when OpenGL view size changes /////////////////////////////////////////////////////////.
(void) - keyDown: [implementation]
 Receiver method called when a key is pressed /////////////////////////////////////////////////////////.
(void) - keyUp: [implementation]
 Receiver method called when a key is released /////////////////////////////////////////////////////////.
(void) - flagsChanged: [implementation]
 Receiver method called when a modifier flag has changed /////////////////////////////////////////////////////////.
(void) - scrollWheel: [implementation]
 Receiver method called when the mouse wheel has been used /////////////////////////////////////////////////////////.
(void) - mouseDown: [implementation]
 Receiver method called when left mouse click is pressed /////////////////////////////////////////////////////////.
(void) - rightMouseDown: [implementation]
 Receiver method called when right mouse click is pressed /////////////////////////////////////////////////////////.
(void) - mouseUp: [implementation]
 Receiver method called when left mouse click is released /////////////////////////////////////////////////////////.
(void) - rightMouseUp: [implementation]
 Receiver method called when right mouse click is released /////////////////////////////////////////////////////////.
(void) - mouseMoved: [implementation]
 Receiver method called when mouse moves /////////////////////////////////////////////////////////.
(void) - mouseDragged: [implementation]
 Receiver method called when mouse is pressed (on left button) and moves /////////////////////////////////////////////////////////.
(void) - rightMouseDragged: [implementation]
 Receiver method called when mouse is pressed (on right button) and moves /////////////////////////////////////////////////////////.
(BOOL) - acceptsFirstResponder [implementation]
 Tells that the view can be focused /////////////////////////////////////////////////////////.
(BOOL) - canBecomeKeyView [implementation]
 Tells that the view can become the key responder (ie. can catch key events) /////////////////////////////////////////////////////////.

Protected Attributes

sf::priv::WindowImplCocoamyDelegate
sfPrivGLContextmyGLContext

Detailed Description

Customized Cocoa OpenGL view /////////////////////////////////////////////////////////.

Definition at line 56 of file GLKit.h.


Member Function Documentation

- (BOOL) acceptsFirstResponder [implementation]

Tells that the view can be focused /////////////////////////////////////////////////////////.

Definition at line 468 of file GLKit.mm.

{
       return YES;
}
- (BOOL) canBecomeKeyView [implementation]

Tells that the view can become the key responder (ie. can catch key events) /////////////////////////////////////////////////////////.

Definition at line 477 of file GLKit.mm.

{
       return YES;
}
- (void) dealloc [implementation]

Clean the instance /////////////////////////////////////////////////////////.

Definition at line 245 of file GLKit.mm.

{
       // Remove the observer and release the OpenGL context
       [[NSNotificationCenter defaultCenter] removeObserver:self];
       [myGLContext release];
       
       [super dealloc];
}
- sf:

Returns the view delegate /////////////////////////////////////////////////////////.

Definition at line 265 of file GLKit.mm.

{
       return myDelegate;
}

Here is the caller graph for this function:

- (void) enableVerticalSync: (bool)  flag

Forward call to en/disable vertical synchronization /////////////////////////////////////////////////////////.

Definition at line 292 of file GLKit.mm.

                          :(bool)flag
{
       GLint enable = (flag) ? 1 : 0;
       [[self openGLContext] setValues:&enable forParameter:NSOpenGLCPSwapInterval];
}

Here is the caller graph for this function:

Finish view setting (after having added it to the window) /////////////////////////////////////////////////////////.

Definition at line 274 of file GLKit.mm.

{
       assert([self superview] != nil);
       assert(myGLContext != nil);
       
       // Attach the OpenGL context to our view
       [self clearGLContext];
       [self setOpenGLContext:myGLContext];
       [myGLContext setView:self];
       
       // Make our view the first responder
       [[self window] makeFirstResponder:self];
}

Here is the caller graph for this function:

- (void) flagsChanged: (NSEvent *)  theEvent [implementation]

Receiver method called when a modifier flag has changed /////////////////////////////////////////////////////////.

Definition at line 380 of file GLKit.mm.

                    :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleModifierKey(theEvent);
}

Here is the call graph for this function:

- (void) flushBuffer

Forward call to flush the OpenGL context /////////////////////////////////////////////////////////.

Definition at line 317 of file GLKit.mm.

{
       [[self openGLContext] flushBuffer];
}

Here is the caller graph for this function:

- (id) initWithFrame: (NSRect)  frame
mode: (const sf::VideoMode&)  mode
settings: (sf::WindowSettings&)  settings 

Make a new view according the the rect , the video mode , the window settings must not be null /////////////////////////////////////////////////////////.

Make a new view according the the rect , the video mode , the window settings and the sf window delegate must not be null /////////////////////////////////////////////////////////.

Definition at line 208 of file GLKit.mm.

                   :(NSRect)frame
                        mode:(const sf::VideoMode&)mode
                 settings:(sf::WindowSettings&)settings
{
       // make the view
       self = [super initWithFrame:frame pixelFormat:nil];
       
       if (self)
       {
              // enabled auto-resizing
              [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
              
              // make the OpenGL context
              myGLContext = [[sfPrivGLContext alloc] initWithAttributes:settings
                                                                                                          mode:mode
                                                                               sharedContext:[sfPrivGLContext sharedContext]];
              
              if (!myGLContext) {
                     [self release];
                     return nil;
              }
              
              // We need to update the OpenGL view when it's resized
              NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
              [nc addObserver:self
                        selector:@selector(viewFrameDidChange:)
                               name:NSViewFrameDidChangeNotification
                             object:self];
       }
       
       return self;
}

Here is the call graph for this function:

- (void) keyDown: (NSEvent *)  theEvent [implementation]

Receiver method called when a key is pressed /////////////////////////////////////////////////////////.

Definition at line 352 of file GLKit.mm.

               :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       
       if (sf::priv::WindowImplCocoa::IsTextEvent((void *)theEvent))
       {
              NSText *field = [[self window] fieldEditor:YES forObject:nil];
              [field interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
              [field setString:@""];
       }
       
       myDelegate->HandleKeyDown(theEvent);
}

Here is the call graph for this function:

- (void) keyUp: (NSEvent *)  theEvent [implementation]

Receiver method called when a key is released /////////////////////////////////////////////////////////.

Definition at line 370 of file GLKit.mm.

             :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleKeyUp(theEvent);
}

Here is the call graph for this function:

- (void) mouseDown: (NSEvent *)  theEvent [implementation]

Receiver method called when left mouse click is pressed /////////////////////////////////////////////////////////.

Definition at line 400 of file GLKit.mm.

                 :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseDown(theEvent);
}

Here is the call graph for this function:

- (void) mouseDragged: (NSEvent *)  theEvent [implementation]

Receiver method called when mouse is pressed (on left button) and moves /////////////////////////////////////////////////////////.

Definition at line 449 of file GLKit.mm.

                    :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseMove(theEvent);
}

Here is the call graph for this function:

- (void) mouseMoved: (NSEvent *)  theEvent [implementation]

Receiver method called when mouse moves /////////////////////////////////////////////////////////.

Definition at line 440 of file GLKit.mm.

                  :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseMove(theEvent);
}

Here is the call graph for this function:

- (void) mouseUp: (NSEvent *)  theEvent [implementation]

Receiver method called when left mouse click is released /////////////////////////////////////////////////////////.

Definition at line 420 of file GLKit.mm.

               :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseUp(theEvent);
}

Here is the call graph for this function:

- (void) pushEvent: (sf::Event sfEvent [implementation]

Send event to the linked window /////////////////////////////////////////////////////////.

Definition at line 326 of file GLKit.mm.

                 :(sf::Event)sfEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleNotifiedEvent(sfEvent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) rightMouseDown: (NSEvent *)  theEvent [implementation]

Receiver method called when right mouse click is pressed /////////////////////////////////////////////////////////.

Definition at line 410 of file GLKit.mm.

                      :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseDown(theEvent);
}

Here is the call graph for this function:

- (void) rightMouseDragged: (NSEvent *)  theEvent [implementation]

Receiver method called when mouse is pressed (on right button) and moves /////////////////////////////////////////////////////////.

Definition at line 458 of file GLKit.mm.

                         :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseMove(theEvent);
}

Here is the call graph for this function:

- (void) rightMouseUp: (NSEvent *)  theEvent [implementation]

Receiver method called when right mouse click is released /////////////////////////////////////////////////////////.

Definition at line 430 of file GLKit.mm.

                    :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseUp(theEvent);
}

Here is the call graph for this function:

- (void) scrollWheel: (NSEvent *)  theEvent [implementation]

Receiver method called when the mouse wheel has been used /////////////////////////////////////////////////////////.

Definition at line 390 of file GLKit.mm.

                   :(NSEvent *)theEvent
{
       assert(myDelegate != NULL);
       myDelegate->HandleMouseWheel(theEvent);
}

Here is the call graph for this function:

- (void) setActive: (bool)  flag

Forward call to set the OpenGL context as active according to /////////////////////////////////////////////////////////.

Definition at line 302 of file GLKit.mm.

                 :(bool)flag
{
       if (flag) {
              if ([NSOpenGLContext currentContext] != [self openGLContext])
                     [[self openGLContext] makeCurrentContext];
       } else {
              if ([NSOpenGLContext currentContext] == [self openGLContext])
                     [NSOpenGLContext clearCurrentContext];
       }
}

Here is the caller graph for this function:

- (void) setDelegate: (sf::priv::WindowImplCocoa *)  aDelegate

Sets as the view delegate /////////////////////////////////////////////////////////.

Definition at line 257 of file GLKit.mm.

                   :(sf::priv::WindowImplCocoa *)aDelegate
{
       myDelegate = aDelegate;
}

Here is the caller graph for this function:

- (void) viewFrameDidChange: (NSNotification *)  notification [implementation]

Notification method receiver when OpenGL view size changes /////////////////////////////////////////////////////////.

Definition at line 336 of file GLKit.mm.

                          :(NSNotification *)notification
{
       [self update];
       
       sf::Event ev;
       ev.Type = sf::Event::Resized;
       ev.Size.Width = (unsigned) [self frame].size.width;
       ev.Size.Height = (unsigned) [self frame].size.height;
       
       [self pushEvent:ev];
}

Here is the call graph for this function:


Member Data Documentation

- sf: [protected]

Definition at line 58 of file GLKit.h.

- (sfPrivGLContext*) myGLContext [protected]

Definition at line 59 of file GLKit.h.


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