aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-06-01 16:13:43 +0000
committerKenneth Russel <[email protected]>2005-06-01 16:13:43 +0000
commit2c06e5f46292ee7e3e4824527e1fe6cf6708df7b (patch)
tree91378332a81fa07594cacba2793f7bc93985bd4b
parentd40e883325b81c5003e664611f72db4a6b8f6220 (diff)
Cleaned up Mac OS X context handling. Removed incorrect retain call on
NSOpenGLContext. Removed NSOpenGLPFANoRecovery and NSOpenGLPFAAccelerated flags from pixel format. Added NSAutoreleasePools around Cocoa calls. Added stereo support. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@292 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r--make/cgl-macosx.cfg1
-rw-r--r--make/stub_includes/macosx/window-system.c1
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m295
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java1
4 files changed, 147 insertions, 151 deletions
diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg
index ac91c252c..447937f1c 100644
--- a/make/cgl-macosx.cfg
+++ b/make/cgl-macosx.cfg
@@ -17,6 +17,7 @@ CustomCCode #include </usr/include/machine/types.h>
CustomCCode extern void* createContext(void* shareContext, void* nsView,
CustomCCode int doubleBuffer,
+CustomCCode int stereo,
CustomCCode int redBits,
CustomCCode int greenBits,
CustomCCode int blueBits,
diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c
index d15406263..5335e6c41 100644
--- a/make/stub_includes/macosx/window-system.c
+++ b/make/stub_includes/macosx/window-system.c
@@ -5,6 +5,7 @@ typedef int Bool;
void* createContext(void* shareContext, void* nsView,
int doubleBuffer,
+ int stereo,
int redBits,
int greenBits,
int blueBits,
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m
index 40a95986f..0b68ee5d4 100644
--- a/src/native/jogl/MacOSXWindowSystemInterface.m
+++ b/src/native/jogl/MacOSXWindowSystemInterface.m
@@ -14,10 +14,9 @@
typedef int Bool;
-NSAutoreleasePool* gAutoreleasePool = NULL;
-
void* createContext(void* shareContext, void* view,
int doubleBuffer,
+ int stereo,
int redBits,
int greenBits,
int blueBits,
@@ -32,164 +31,163 @@ void* createContext(void* shareContext, void* view,
int numSamples,
int* viewNotReady)
{
- int colorSize = redBits + greenBits + blueBits;
- int accumSize = accumRedBits + accumGreenBits + accumBlueBits;
+ int colorSize = redBits + greenBits + blueBits;
+ int accumSize = accumRedBits + accumGreenBits + accumBlueBits;
- NSOpenGLContext *nsChareCtx = (NSOpenGLContext*)shareContext;
- NSView *nsView = (NSView*)view;
-
- if (nsView != NULL)
- {
- if ([nsView lockFocusIfCanDraw] == NO)
- {
- if (viewNotReady != NULL) {
- *viewNotReady = 1;
- }
-
- // the view is not ready yet
- return NULL;
- }
- }
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ NSOpenGLContext *nsChareCtx = (NSOpenGLContext*)shareContext;
+ NSView *nsView = (NSView*)view;
+
+ if (nsView != NULL) {
+ if ([nsView lockFocusIfCanDraw] == NO) {
+ if (viewNotReady != NULL) {
+ *viewNotReady = 1;
+ }
+
+ // the view is not ready yet
+ [pool release];
+ return NULL;
+ }
+ }
- if (gAutoreleasePool == NULL)
- {
- gAutoreleasePool = [[NSAutoreleasePool alloc] init];
- }
-
- NSOpenGLPixelFormatAttribute attribs[] =
- {
- NSOpenGLPFANoRecovery, YES,
- NSOpenGLPFAAccelerated, YES,
- NSOpenGLPFADoubleBuffer, YES,
- NSOpenGLPFAColorSize, colorSize,
- NSOpenGLPFAAlphaSize, alphaBits,
- NSOpenGLPFADepthSize, depthBits,
- NSOpenGLPFAStencilSize, stencilBits,
- NSOpenGLPFAAccumSize, accumSize,
- NSOpenGLPFASampleBuffers, sampleBuffers,
- NSOpenGLPFASamples, numSamples,
- 0
- };
-
-
-
- NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
-
- NSOpenGLContext* nsContext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nsChareCtx];
-
- [fmt release];
+ NSOpenGLPixelFormatAttribute attribs[256];
+ int idx = 0;
+ if (doubleBuffer) attribs[idx++] = NSOpenGLPFADoubleBuffer;
+ if (stereo) attribs[idx++] = NSOpenGLPFAStereo;
+ attribs[idx++] = NSOpenGLPFAColorSize; attribs[idx++] = colorSize;
+ attribs[idx++] = NSOpenGLPFAAlphaSize; attribs[idx++] = alphaBits;
+ attribs[idx++] = NSOpenGLPFADepthSize; attribs[idx++] = depthBits;
+ attribs[idx++] = NSOpenGLPFAStencilSize; attribs[idx++] = stencilBits;
+ attribs[idx++] = NSOpenGLPFAAccumSize; attribs[idx++] = accumSize;
+ attribs[idx++] = NSOpenGLPFASampleBuffers; attribs[idx++] = sampleBuffers;
+ attribs[idx++] = NSOpenGLPFASamples; attribs[idx++] = numSamples;
+ attribs[idx++] = 0;
+
+ NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc]
+ initWithAttributes:attribs];
+ NSOpenGLContext* nsContext = [[NSOpenGLContext alloc]
+ initWithFormat:fmt
+ shareContext:nsChareCtx];
+ [fmt release];
- if (nsView != nil)
- {
- [nsContext setView:nsView];
-
- [nsView unlockFocus];
- }
-
- [nsContext retain];
-
-//fprintf(stderr, " nsContext=%p\n", nsContext);
- return nsContext;
+ if (nsView != nil) {
+ [nsContext setView:nsView];
+ [nsView unlockFocus];
+ }
+
+ [pool release];
+ return nsContext;
}
-Bool makeCurrentContext(void* context, void* view)
-{
-//fprintf(stderr, "makeCurrentContext context=%p, view=%p\n", context, view);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+Bool makeCurrentContext(void* context, void* view) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- [nsContext makeCurrentContext];
- return true;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext makeCurrentContext];
+ [pool release];
+ return true;
}
-Bool clearCurrentContext(void* context, void* view)
-{
-//fprintf(stderr, "clearCurrentContext context=%p, view=%p\n", context, view);
- [NSOpenGLContext clearCurrentContext];
- return true;
+Bool clearCurrentContext(void* context, void* view) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [NSOpenGLContext clearCurrentContext];
+ [pool release];
+ return true;
}
-Bool deleteContext(void* context, void* view)
-{
-//fprintf(stderr, "deleteContext context=%p, view=%p\n", context, view);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+Bool deleteContext(void* context, void* view) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- [nsContext clearDrawable];
- [nsContext release];
- return true;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext clearDrawable];
+ [nsContext release];
+ [pool release];
+ return true;
}
-Bool flushBuffer(void* context, void* view)
-{
-//fprintf(stderr, "flushBuffer context=%p, view=%p\n", context, view);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+Bool flushBuffer(void* context, void* view) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- [nsContext flushBuffer];
- return true;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext flushBuffer];
+ [pool release];
+ return true;
}
-void updateContext(void* context, void* view)
-{
-//fprintf(stderr, "updateContext context=%p, view=%p\n", context, view);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+void updateContext(void* context, void* view) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- [nsContext update];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext update];
+ [pool release];
}
-void* updateContextRegister(void* context, void* view)
-{
-//fprintf(stderr, "updateContextRegister context=%p, view=%p\n", context, view);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- NSView *nsView = (NSView*)view;
+void* updateContextRegister(void* context, void* view) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+ NSView *nsView = (NSView*)view;
- ContextUpdater *contextUpdater = [[ContextUpdater alloc] init];
- [contextUpdater registerFor:nsContext with:nsView];
- return NULL;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ ContextUpdater *contextUpdater = [[ContextUpdater alloc] init];
+ [contextUpdater registerFor:nsContext with:nsView];
+ [pool release];
+ return NULL;
}
-void updateContextUnregister(void* context, void* view, void* updater)
-{
-//fprintf(stderr, "updateContextUnregister context=%p, view=%p\n", context, view);
- ContextUpdater *contextUpdater = (ContextUpdater *)updater;
+void updateContextUnregister(void* context, void* view, void* updater) {
+ ContextUpdater *contextUpdater = (ContextUpdater *)updater;
- [contextUpdater release];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [contextUpdater release];
+ [pool release];
}
-void* createPBuffer(int renderTarget, int internalFormat, int width, int height)
-{
- // fprintf(stderr, "createPBuffer renderTarget=%d internalFormat=%d width=%d height=%d\n", renderTarget, internalFormat, width, height);
-
- NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:renderTarget textureInternalFormat:internalFormat textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height];
-
+void* createPBuffer(int renderTarget, int internalFormat, int width, int height) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc]
+ initWithTextureTarget:renderTarget
+ textureInternalFormat:internalFormat
+ textureMaxMipMapLevel:0
+ pixelsWide:width
+ pixelsHigh:height];
+ [pool release];
return pBuffer;
}
-Bool destroyPBuffer(void* context, void* buffer)
-{
-//fprintf(stderr, "destroyPBuffer context=%p, buffer=%p\n", context, buffer);
- NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
- NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
+Bool destroyPBuffer(void* context, void* buffer) {
+ NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
+ NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
- if (nsContext != NULL)
- {
- [nsContext clearDrawable];
- }
- [pBuffer release];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ if (nsContext != NULL) {
+ [nsContext clearDrawable];
+ }
+ [pBuffer release];
+ [pool release];
- return true;
+ return true;
}
void setContextPBuffer(void* context, void* buffer) {
NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
- [nsContext setPixelBuffer: pBuffer cubeMapFace: 0 mipMapLevel: 0 currentVirtualScreen: [nsContext currentVirtualScreen]];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext setPixelBuffer: pBuffer
+ cubeMapFace: 0
+ mipMapLevel: 0
+ currentVirtualScreen: [nsContext currentVirtualScreen]];
+ [pool release];
}
void setContextTextureImageToPBuffer(void* context, void* buffer, int colorBuffer) {
NSOpenGLContext *nsContext = (NSOpenGLContext*)context;
NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer;
- [nsContext setTextureImageToPixelBuffer: pBuffer colorBuffer: (unsigned long) colorBuffer];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [nsContext setTextureImageToPixelBuffer: pBuffer
+ colorBuffer: (unsigned long) colorBuffer];
+ [pool release];
}
#include <mach-o/dyld.h>
@@ -198,39 +196,34 @@ static char libGLStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/
static char libGLUStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib";
static const struct mach_header *libGLImage;
static const struct mach_header *libGLUImage;
-void* getProcAddress(const char *procname)
-{
- if (imagesInitialized == false)
- {
- imagesInitialized = true;
- unsigned long options = NSADDIMAGE_OPTION_RETURN_ON_ERROR;
- libGLImage = NSAddImage(libGLStr, options);
- libGLUImage = NSAddImage(libGLUStr, options);
- }
-
- unsigned long options = NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
- char underscoreName[512] = "_";
- strcat(underscoreName, procname);
-
- if (NSIsSymbolNameDefinedInImage(libGLImage, underscoreName) == YES)
- {
- NSSymbol sym = NSLookupSymbolInImage(libGLImage, underscoreName, options);
- return NSAddressOfSymbol(sym);
- }
-
- if (NSIsSymbolNameDefinedInImage(libGLUImage, underscoreName) == YES)
- {
- NSSymbol sym = NSLookupSymbolInImage(libGLUImage, underscoreName, options);
- return NSAddressOfSymbol(sym);
- }
-
- if (NSIsSymbolNameDefinedWithHint(underscoreName, "GL"))
- {
- NSSymbol sym = NSLookupAndBindSymbol(underscoreName);
- return NSAddressOfSymbol(sym);
- }
-
- return NULL;
+void* getProcAddress(const char *procname) {
+ if (imagesInitialized == false) {
+ imagesInitialized = true;
+ unsigned long options = NSADDIMAGE_OPTION_RETURN_ON_ERROR;
+ libGLImage = NSAddImage(libGLStr, options);
+ libGLUImage = NSAddImage(libGLUStr, options);
+ }
+
+ unsigned long options = NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
+ char underscoreName[512] = "_";
+ strcat(underscoreName, procname);
+
+ if (NSIsSymbolNameDefinedInImage(libGLImage, underscoreName) == YES) {
+ NSSymbol sym = NSLookupSymbolInImage(libGLImage, underscoreName, options);
+ return NSAddressOfSymbol(sym);
+ }
+
+ if (NSIsSymbolNameDefinedInImage(libGLUImage, underscoreName) == YES) {
+ NSSymbol sym = NSLookupSymbolInImage(libGLUImage, underscoreName, options);
+ return NSAddressOfSymbol(sym);
+ }
+
+ if (NSIsSymbolNameDefinedWithHint(underscoreName, "GL")) {
+ NSSymbol sym = NSLookupAndBindSymbol(underscoreName);
+ return NSAddressOfSymbol(sym);
+ }
+
+ return NULL;
}
void setSwapInterval(void* context, int interval) {
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
index 6e474f2ce..e4fe8c4b7 100644
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
@@ -134,6 +134,7 @@ public abstract class MacOSXGLContext extends GLContext
nsContext = CGL.createContext(share,
nsView,
capabilities.getDoubleBuffered() ? 1 : 0,
+ capabilities.getStereo() ? 1 : 0,
capabilities.getRedBits(),
capabilities.getGreenBits(),
capabilities.getBlueBits(),