diff options
author | Gerard Ziemski <[email protected]> | 2003-11-04 19:27:09 +0000 |
---|---|---|
committer | Gerard Ziemski <[email protected]> | 2003-11-04 19:27:09 +0000 |
commit | b0cb7e5faf5f0b5a7f4cfe31e49be9342b36e0a3 (patch) | |
tree | 46ddbf028166d239b74af28eea013e537a739835 | |
parent | f516d8cdc25577dd1227b85578d361749ab8063d (diff) |
Print error messages when nsview is not a valid drawable and return NULL from createContext
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@70 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | src/native/jogl/MacOSXWindowSystemInterface.m | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index 3d852571c..2d812ec58 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -16,6 +16,23 @@ void* createContext(void* shareContext, void* view) NSOpenGLContext *nsChareCtx = (NSOpenGLContext*)shareContext; NSView *nsView = (NSView*)view; + if (nsView != NULL) + { + NSRect frame = [nsView frame]; + if ((frame.size.width == 0) || (frame.size.height == 0)) + { + fprintf(stderr, "Error: empty view at \"%s:%s:%d\"\n", __FILE__, __FUNCTION__, __LINE__); + // the view is not ready yet + return NULL; + } + else if ([nsView lockFocusIfCanDraw] == NO) + { + fprintf(stderr, "Error: view not ready at \"%s:%s:%d\"\n", __FILE__, __FUNCTION__, __LINE__); + // the view is not ready yet + return NULL; + } + } + if (gAutoreleasePool == NULL) { gAutoreleasePool = [[NSAutoreleasePool alloc] init]; @@ -41,7 +58,7 @@ void* createContext(void* shareContext, void* view) if (nsView == NULL) { - attribs[12] = 0; // no stencil, no accums fo pBuffers + attribs[12] = 0; // no stencil, no accums for pBuffers } NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; @@ -49,15 +66,16 @@ void* createContext(void* shareContext, void* view) NSOpenGLContext* nsContext = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nsChareCtx]; [fmt release]; - + if (nsView != nil) { - [nsContext setView: nsView]; + [nsContext setView:nsView]; + + [nsView unlockFocus]; } - + [nsContext retain]; -//fprintf(stderr, " nsContext=%p\n", nsContext); return nsContext; } |