summaryrefslogtreecommitdiff
path: root/macosx/plugins/PeopsXgl/macsrc
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-17 20:06:59 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-17 20:06:59 +0000
commit37ba81a540460a7d34a33c23d2353ac84f887576 (patch)
tree64490fe788c3efbc894bc4e418e098e8696a8040 /macosx/plugins/PeopsXgl/macsrc
parent30195666f40ca64b0bdf34ed783215d27f000cd7 (diff)
downloadpcsxr-37ba81a540460a7d34a33c23d2353ac84f887576.tar.gz
Make more plug-ins use and implement RunOnMainThreadSync.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86706 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/PeopsXgl/macsrc')
-rwxr-xr-xmacosx/plugins/PeopsXgl/macsrc/PluginGLView.h9
-rwxr-xr-xmacosx/plugins/PeopsXgl/macsrc/PluginGLView.m64
-rwxr-xr-xmacosx/plugins/PeopsXgl/macsrc/drawgl.m30
3 files changed, 59 insertions, 44 deletions
diff --git a/macosx/plugins/PeopsXgl/macsrc/PluginGLView.h b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.h
index 5964a0c0..a1d7bd03 100755
--- a/macosx/plugins/PeopsXgl/macsrc/PluginGLView.h
+++ b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.h
@@ -24,6 +24,15 @@
#define IMAGE_COUNT 2
+static inline void RunOnMainThreadSync(dispatch_block_t block)
+{
+ if ([NSThread isMainThread]) {
+ block();
+ } else {
+ dispatch_sync(dispatch_get_main_queue(), block);
+ }
+}
+
@interface PluginGLView : NSOpenGLView
{
struct timeval cycle_time;
diff --git a/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m
index 4e8b8c67..b2ec911a 100755
--- a/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m
+++ b/macosx/plugins/PeopsXgl/macsrc/PluginGLView.m
@@ -33,33 +33,39 @@
@implementation PluginGLView
-- (BOOL)isOpaque { return YES; }
-- (BOOL)acceptsFirstResponder { return NO; }
+- (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)
+ // 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) {
AUTORELEASEOBJNORETURN(self);
return nil;
}
-
+
// Init pixel format attribs
NSOpenGLPixelFormatAttribute attrs[] =
{
NSOpenGLPFAAccelerated,
NSOpenGLPFANoRecovery,
NSOpenGLPFADoubleBuffer,
-// NSOpenGLPFASampleBuffers, 1, // For full screen AA when implemented
-// NSOpenGLPFASamples, 2,
+ //NSOpenGLPFASampleBuffers, 1, // For full screen AA when implemented
+ //NSOpenGLPFASamples, 2,
0
};
-
+
// Get pixel format from OpenGL
NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
if (!pixFmt)
@@ -71,7 +77,7 @@
NSOpenGLPFANoRecovery,
0
};
-
+
// Get pixel format from OpenGL
pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs2];
if (!pixFmt) {
@@ -83,11 +89,11 @@
}
[self setPixelFormat:AUTORELEASEOBJ(pixFmt)];
-
+
[[self openGLContext] makeCurrentContext];
-
- // we're done, dude.
-
+
+ // we're done, dude.
+
// Call for a redisplay
noDisplay = YES; // hm, this can be deleted I think
PSXDisplay.Disabled = 1;
@@ -109,21 +115,21 @@
- (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);
+
+ [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.
+ [[self openGLContext] flushBuffer];
+
+ //[NSOpenGLContext clearCurrentContext]; // this makes bad things happen, so screw it.
[glLock unlock];
- return;
+ return;
}
- (void)swapBuffer
@@ -142,7 +148,7 @@
//[self loadTextures:NO];
} else {
noDisplay = YES;
- // [self setNeedsDisplay:true];
+ // [self setNeedsDisplay:true];
}
}
diff --git a/macosx/plugins/PeopsXgl/macsrc/drawgl.m b/macosx/plugins/PeopsXgl/macsrc/drawgl.m
index c2714769..550b3d72 100755
--- a/macosx/plugins/PeopsXgl/macsrc/drawgl.m
+++ b/macosx/plugins/PeopsXgl/macsrc/drawgl.m
@@ -133,29 +133,29 @@ void DoClearFrontBuffer(void) // CLEAR DX BUFFER
unsigned long ulInitDisplay(void) // OPEN GAME WINDOW
{
- bUsingTWin=FALSE;
-
-// InitMenu(); // This function does nothing
-
+ bUsingTWin = FALSE;
+
+ //InitMenu(); // This function does nothing
+
bIsFirstFrame = FALSE;
-
+
if(iShowFPS)
{
//iShowFPS=0;
- ulKeybits|=KEY_SHOWFPS;
- szDispBuf[0]=0;
+ ulKeybits |= KEY_SHOWFPS;
+ szDispBuf[0] = 0;
BuildDispMenu(0);
}
- __block PluginWindowController *windowController;
-
- // this causes a runtime error if it's done on a thread other than the main thread
- dispatch_sync(dispatch_get_main_queue(), ^{
- windowController = [PluginWindowController openGameView];
- glView = [windowController openGLView];
+ __block PluginWindowController *windowController;
- [[windowController window] setTitle:@(pCaptionText)];
- });
+ // this causes a runtime error if it's done on a thread other than the main thread
+ RunOnMainThreadSync(^{
+ windowController = [PluginWindowController openGameView];
+ glView = [windowController openGLView];
+
+ [[windowController window] setTitle:@(pCaptionText)];
+ });
return (unsigned long)[windowController window];
}