diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-02-18 08:58:58 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-02-18 08:58:58 +0000 |
| commit | 34cfcc5169cafa8ae9e0d6469e20dc11c122c077 (patch) | |
| tree | 47ddff4f53156e888c370b12c405a6849a9cb2a6 /macosx/plugins/PeopsXgl/macsrc/PluginGLView.m | |
| parent | 394f7a2b4a604dc40cf29f23a7121deb19eed79c (diff) | |
| download | pcsxr-34cfcc5169cafa8ae9e0d6469e20dc11c122c077.tar.gz | |
-(SysBeep)Added Mac OS X port of P.E.Op.S OpenGL plugin. (Patch #8361)
-Fixed help message for Windows. (Issue #8028).
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@63522 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/PeopsXgl/macsrc/PluginGLView.m')
| -rw-r--r-- | macosx/plugins/PeopsXgl/macsrc/PluginGLView.m | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m new file mode 100644 index 00000000..feb483a9 --- /dev/null +++ b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m @@ -0,0 +1,135 @@ +/*************************************************************************** + PluginGLView.m + a view within game window, rudimentary OpenGL setup + maintainence + Also, I clear the gl screen with a beautiful yellow color for + debugging purposes. + + PeopsOpenGLGPU + + Created by Gil Pedersen on Sun April 18 2004. + Copyright (c) 2004 Gil Pedersen. + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + +#import <OpenGL/gl.h> +#import <OpenGL/glext.h> +#import <OpenGL/glu.h> +//#import <GLUT/glut.h> +//#import <Carbon/Carbon.h> +#import "PluginGLView.h" +#include "externals.h" // for PSXDisplay.disable -- should move it elsewhere really +#undef BOOL + +@implementation PluginGLView + +- (BOOL)isOpaque { return YES; } +- (BOOL)acceptsFirstResponder { return NO; } + + +- (id) initWithCoder: (NSCoder *) coder +{ + // Set up pixel format on creation + // and, well, that's about it. + if ((self = [super initWithCoder:coder]) == nil) + return nil; + + glLock = [[NSLock alloc] init]; + if (nil == glLock) { + [self release]; + return nil; + } + + // Init pixel format attribs + NSOpenGLPixelFormatAttribute attrs[] = + { + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADoubleBuffer, +// NSOpenGLPFASampleBuffers, 1, // For full screen AA when implemented +// NSOpenGLPFASamples, 2, + 0 + }; + + // Get pixel format from OpenGL + NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; + if (!pixFmt) + { + NSLog(@"No Accelerated OpenGL pixel format found\n"); + + NSOpenGLPixelFormatAttribute attrs2[] = + { + NSOpenGLPFANoRecovery, + 0 + }; + + // Get pixel format from OpenGL + pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs2]; + if (!pixFmt) { + NSLog(@"No OpenGL pixel format found!\n"); + + [self release]; + return nil; + } + } + + [self setPixelFormat:[pixFmt autorelease]]; + + [[self openGLContext] makeCurrentContext]; + + // we're done, dude. + + // Call for a redisplay + noDisplay = YES; // hm, this can be deleted I think + PSXDisplay.Disabled = 1; + [self setNeedsDisplay:true]; + + return self; +} + +- (void)dealloc +{ + [[self openGLContext] makeCurrentContext]; // just in case + [NSOpenGLContext clearCurrentContext]; + [glLock release]; + [super dealloc]; +} + + +- (void)reshape // scrolled, moved or resized +{ + [super reshape]; + + [glLock lock]; // not sure if needed, but hey + [[self openGLContext] makeCurrentContext]; + + NSRect rect = [self bounds]; + rect.size = [self convertSize:rect.size toView:nil]; + glViewport(0.0, 0.0, NSWidth(rect), NSHeight(rect)); + + glClearColor (1.0, 0.5, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + [[self openGLContext] flushBuffer]; + +// [NSOpenGLContext clearCurrentContext]; // this makes bad things happen, so screw it. + [glLock unlock]; + return; +} + +- (void)swapBuffer +{ + // actually not much to do here. + [[self openGLContext] flushBuffer]; + return; + } + + +@end |
