filename | src/drivers/video_nsgl.m |
changeset | 1076:18c164e8aec4 |
prev | 964:f2f3c7612d06 |
next | 1134:f502f3d32f90 |
author | nkeynes |
date | Sun Jan 31 18:35:06 2010 +1000 (14 years ago) |
permissions | -rw-r--r-- |
last change | Refactor CDROM host support - Completely separate GDROM hardware (in gdrom/gdrom.c) from generic CDROM support (now in drivers/cdrom) - Add concept of 'sector sources' that can be mixed and matched to create cdrom discs (makes support of arbitrary disc types much simpler) |
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 <Foundation/NSAutoreleasePool.h>
21 #include "drivers/video_nsgl.h"
22 #include "drivers/video_gl.h"
23 #include "pvr2/glutil.h"
25 static NSOpenGLContext *nsgl_context = nil;
27 gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )
28 {
29 NSAutoreleasePool *pool = [NSAutoreleasePool new];
30 NSOpenGLPixelFormatAttribute attributes[] = {
31 NSOpenGLPFAWindow,
32 // NSOpenGLPFADoubleBuffer,
33 NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
34 (NSOpenGLPixelFormatAttribute)nil };
36 NSOpenGLPixelFormat *pixelFormat =
37 [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];
38 nsgl_context =
39 [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
40 [nsgl_context setView: view];
41 [nsgl_context makeCurrentContext];
42 [pool release];
43 driver->swap_buffers = video_nsgl_swap_buffers;
44 if( gl_fbo_is_supported() ) {
45 gl_fbo_init(driver);
46 } else {
47 /* Note there is a 'native' buffer framework, but since all current
48 * Apple drivers appear to support FBO, there's not much point in
49 * doing the work to support them.
50 */
51 ERROR( "FBO not supported" );
52 return FALSE;
53 }
55 return TRUE;
56 }
58 void video_nsgl_update()
59 {
60 if( nsgl_context != nil ) {
61 [nsgl_context update];
62 }
63 }
65 void video_nsgl_make_current()
66 {
67 if( nsgl_context != nil ) {
68 [nsgl_context makeCurrentContext];
69 }
70 }
72 void video_nsgl_swap_buffers()
73 {
74 if( nsgl_context != nil ) {
75 [nsgl_context flushBuffer];
76 }
77 }
79 void video_nsgl_shutdown()
80 {
81 if( nsgl_context != nil ) {
82 [NSOpenGLContext clearCurrentContext];
83 [nsgl_context release];
84 nsgl_context = nil;
85 }
86 }
.