1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/video_nsgl.m Sat Jun 13 00:50:48 2009 +0000
1.7 + * Cocoa (NSOpenGL) video driver
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.22 +#include <AppKit/NSOpenGL.h>
1.23 +#include <Foundation/NSAutoreleasePool.h>
1.24 +#include "drivers/video_nsgl.h"
1.25 +#include "drivers/video_gl.h"
1.26 +#include "pvr2/glutil.h"
1.28 +static NSOpenGLContext *nsgl_context = nil;
1.30 +gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )
1.32 + NSAutoreleasePool *pool = [NSAutoreleasePool new];
1.33 + NSOpenGLPixelFormatAttribute attributes[] = {
1.34 + NSOpenGLPFAWindow,
1.35 + // NSOpenGLPFADoubleBuffer,
1.36 + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
1.37 + (NSOpenGLPixelFormatAttribute)nil };
1.39 + NSOpenGLPixelFormat *pixelFormat =
1.40 + [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];
1.42 + [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
1.43 + [nsgl_context setView: view];
1.44 + [nsgl_context makeCurrentContext];
1.46 + if( gl_fbo_is_supported() ) {
1.47 + gl_fbo_init(driver);
1.49 + ERROR( "FBO not supported" );
1.56 +void video_nsgl_update()
1.58 + if( nsgl_context != nil ) {
1.59 + [nsgl_context update];
1.63 +void video_nsgl_make_current()
1.65 + if( nsgl_context != nil ) {
1.66 + [nsgl_context makeCurrentContext];
1.70 +void video_nsgl_swap_buffers()
1.72 + if( nsgl_context != nil ) {
1.73 + [nsgl_context flushBuffer];
1.77 +void video_nsgl_shutdown()
1.79 + if( nsgl_context != nil ) {
1.80 + [NSOpenGLContext clearCurrentContext];
1.81 + [nsgl_context release];
1.82 + nsgl_context = nil;