4 * Cocoa (NSOpenGL) video driver
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <AppKit/NSOpenGL.h>
20 #include "drivers/video_nsgl.h"
21 #include "drivers/video_gl.h"
22 #include "pvr2/glutil.h"
24 static NSOpenGLContext *nsgl_context = nil;
26 gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )
28 NSAutoreleasePool *pool = [NSAutoreleasePool new];
29 NSOpenGLPixelFormatAttribute attributes[] = {
31 // NSOpenGLPFADoubleBuffer,
32 NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
33 (NSOpenGLPixelFormatAttribute)nil };
35 NSOpenGLPixelFormat *pixelFormat =
36 [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];
38 [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
39 [nsgl_context setView: view];
40 [nsgl_context makeCurrentContext];
42 if( gl_fbo_is_supported() ) {
45 ERROR( "FBO not supported" );
52 void video_nsgl_update()
54 if( nsgl_context != nil ) {
55 [nsgl_context update];
59 void video_nsgl_make_current()
61 if( nsgl_context != nil ) {
62 [nsgl_context makeCurrentContext];
66 void video_nsgl_swap_buffers()
68 if( nsgl_context != nil ) {
69 [nsgl_context flushBuffer];
73 void video_nsgl_shutdown()
75 if( nsgl_context != nil ) {
76 [NSOpenGLContext clearCurrentContext];
77 [nsgl_context release];
.