Search
lxdream.org :: lxdream/src/drivers/video_nsgl.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_nsgl.c
changeset 665:99ae9dc4cab7
prev663:553bb7d6befa
next681:1755a126b109
author nkeynes
date Sat Apr 19 00:36:36 2008 +0000 (14 years ago)
permissions -rw-r--r--
last change Move glsl setup out of the drivers
Move pvr2 setup call up to video_gtk (probably needs to go higher really)
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Cocoa (NSOpenGL) video driver
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    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;
    26 gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )
    27 {
    28 	NSOpenGLPixelFormatAttribute attributes[] = {
    29 			NSOpenGLPFAWindow,
    30 			NSOpenGLPFADoubleBuffer,
    31 			NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
    32 			(NSOpenGLPixelFormatAttribute)nil };
    34 	NSOpenGLPixelFormat *pixelFormat = 
    35 		[[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];
    36 	nsgl_context = 
    37 		[[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
    38 	[nsgl_context setView: view];
    39 	[nsgl_context makeCurrentContext];
    41 	if( gl_fbo_is_supported() ) {
    42 		gl_fbo_init(driver);
    43 	} else {
    44 		ERROR( "FBO not supported" );
    45 		return FALSE;
    46 	}
    48 	return TRUE;
    49 }
    51 void video_nsgl_shutdown()
    52 {
    53 	if( nsgl_context != nil ) {
    54 		[NSOpenGLContext clearCurrentContext];
    55 		[nsgl_context release];
    56 		nsgl_context = nil;
    57 	}
    58 }
.