summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2003-09-05 16:25:38 +0000
committerKenneth Russel <[email protected]>2003-09-05 16:25:38 +0000
commit88dba17d799c1faf2b3185636a8e6cc1e021b80c (patch)
treee8d03891b4d54d013111891d3b0726bc9b0c81cc
parent4c6d717f37d4a6cf50fd06056f1a2357815a9ccf (diff)
Added Gerard Ziemski's new sources for faster dynamic symbol lookup on
Mac OS X. Removed workarounds for earlier JAWT bugs on OS X. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@60 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m57
-rw-r--r--src/net/java/games/jogl/GLCanvas.java20
2 files changed, 42 insertions, 35 deletions
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m
index 11188f377..0499984c3 100644
--- a/src/native/jogl/MacOSXWindowSystemInterface.m
+++ b/src/native/jogl/MacOSXWindowSystemInterface.m
@@ -6,7 +6,7 @@ typedef int Bool;
void* createContext(void* nsView, void* shareContext) {
NSView *view = nsView;
NSOpenGLContext *share = shareContext;
-
+
// FIXME: hardcoded pixel format. Instead pass these attributes down
// as arguments. There is really no way to enumerate the possible
// pixel formats for a given window on Mac OS X, so we will assume
@@ -24,16 +24,14 @@ void* createContext(void* nsView, void* shareContext) {
NSOpenGLPFAAccumSize, 0,
0
};
-
- NSRect rect = [view frame];
-
- NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs];
-
+
+ NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs];
+
NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat: [fmt autorelease] shareContext: share];
-
+
if (view != nil) {
[context setView: view];
-
+
[context makeCurrentContext];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
[context update];
@@ -45,7 +43,7 @@ void* createContext(void* nsView, void* shareContext) {
Bool makeCurrentContext(void* nsView, void* nsContext) {
NSOpenGLContext *context = nsContext;
-
+
[context makeCurrentContext];
return true;
}
@@ -53,7 +51,7 @@ Bool makeCurrentContext(void* nsView, void* nsContext) {
Bool clearCurrentContext(void* nsView, void* nsContext) {
NSView *view = nsView;
NSOpenGLContext *context = nsContext;
-
+
[NSOpenGLContext clearCurrentContext];
return true;
}
@@ -61,13 +59,13 @@ Bool clearCurrentContext(void* nsView, void* nsContext) {
void updateContext(void* nsView, void* nsContext) {
NSView *view = nsView;
NSOpenGLContext *context = nsContext;
-
+
[context update];
}
Bool deleteContext(void* nsView, void* nsContext) {
NSOpenGLContext *context = nsContext;
-
+
[context setView: nil];
[context release];
return true;
@@ -82,14 +80,37 @@ Bool flushBuffer(void* nsView, void* nsContext) {
#include <mach-o/dyld.h>
+Bool imagesInitialized = false;
+static char libGLStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
+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) {
- void *funcPtr = NULL;
- static char underscoreName[256];
- strcpy(underscoreName, "_");
+ 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 (NSIsSymbolNameDefined(underscoreName)) {
+
+ 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);
- funcPtr = (void *)NSAddressOfSymbol(sym);
+ return NSAddressOfSymbol(sym);
}
- return funcPtr;
+
+ return NULL;
}
diff --git a/src/net/java/games/jogl/GLCanvas.java b/src/net/java/games/jogl/GLCanvas.java
index d5f6dbfdc..527289fdc 100644
--- a/src/net/java/games/jogl/GLCanvas.java
+++ b/src/net/java/games/jogl/GLCanvas.java
@@ -61,10 +61,6 @@ public final class GLCanvas extends Canvas implements GLDrawable {
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
private GLContext context;
- // FIXME: Temporary workaround for JAWT bug in Panther developer release.
- // This workaround makes things quite a bit slower
- private static final boolean isOSX = System.getProperty("os.name").equals("Mac OS X");
-
GLCanvas(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
GLDrawable shareWith) {
@@ -83,24 +79,14 @@ public final class GLCanvas extends Canvas implements GLDrawable {
}
public void display() {
- if (isOSX) {
- // Temporary workaround for JAWT bug in Panther developer release.
- // All OpenGL rendering must occur on the AWT event thread.
- repaint();
- } else {
- displayImpl();
- }
+ displayImpl();
}
/** Overridden from Canvas; calls {@link #display}. Should not be
invoked by applications directly. */
public void paint(Graphics g) {
- if (isOSX) {
- displayImpl();
- } else {
- if (!context.getNoAutoRedrawMode()) {
- display();
- }
+ if (!context.getNoAutoRedrawMode()) {
+ display();
}
}