Search
lxdream.org :: lxdream/src/drivers/video_nsgl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_nsgl.c
changeset 663:553bb7d6befa
next665:99ae9dc4cab7
author nkeynes
date Thu Apr 17 08:15:19 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Commit NSGL work-in-progress
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/video_nsgl.c Thu Apr 17 08:15:19 2008 +0000
1.3 @@ -0,0 +1,63 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Cocoa (NSOpenGL) video driver
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
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.15 + *
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.20 + */
1.21 +
1.22 +#include <AppKit/NSOpenGL.h>
1.23 +#include "drivers/video_nsgl.h"
1.24 +#include "drivers/video_gl.h"
1.25 +#include "pvr2/glutil.h"
1.26 +
1.27 +static NSOpenGLContext *nsgl_context;
1.28 +
1.29 +gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )
1.30 +{
1.31 + NSOpenGLPixelFormatAttribute attributes[] = {
1.32 + NSOpenGLPFAWindow,
1.33 + NSOpenGLPFADoubleBuffer,
1.34 + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
1.35 + (NSOpenGLPixelFormatAttribute)nil };
1.36 +
1.37 + NSOpenGLPixelFormat *pixelFormat =
1.38 + [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];
1.39 + nsgl_context =
1.40 + [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];
1.41 + [nsgl_context setView: view];
1.42 + [nsgl_context makeCurrentContext];
1.43 +
1.44 + if( gl_fbo_is_supported() ) {
1.45 + gl_fbo_init(driver);
1.46 + } else {
1.47 + ERROR( "FBO not supported" );
1.48 + return FALSE;
1.49 + }
1.50 +
1.51 + if( glsl_is_supported() ) {
1.52 + if( !glsl_load_shaders( glsl_vertex_shader_src, NULL ) ) {
1.53 + WARN( "Unable to load GL shaders" );
1.54 + }
1.55 + }
1.56 + return TRUE;
1.57 +}
1.58 +
1.59 +void video_nsgl_shutdown()
1.60 +{
1.61 + if( nsgl_context != nil ) {
1.62 + [NSOpenGLContext clearCurrentContext];
1.63 + [nsgl_context release];
1.64 + nsgl_context = nil;
1.65 + }
1.66 +}
.