aboutsummaryrefslogtreecommitdiffstats
path: root/src/native
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2003-06-26 13:21:12 +0000
committerKenneth Russel <[email protected]>2003-06-26 13:21:12 +0000
commit0a6e191eaebcc8edc2611dbedab6fd04a615fc2f (patch)
tree7f8a9b8e88a6bc6662827d3f092b943b1ea893fb /src/native
parent2b54833bb15d6cae356fa0c5777d11e152d774cb (diff)
Initial Mac OS X port of Jogl by Gerard Ziemski and Kenneth Russell,
subsuming the previous prototype implementation (no GLCanvas support) done by Marc Downie. Added user's guide (HTML format) under doc/userguide/index.html. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@13 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/native')
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m
new file mode 100644
index 000000000..074b98b2a
--- /dev/null
+++ b/src/native/jogl/MacOSXWindowSystemInterface.m
@@ -0,0 +1,94 @@
+#import <Cocoa/Cocoa.h>
+#import <OpenGL/gl.h>
+
+typedef int Bool;
+
+void* createContext(void* nsView) {
+ NSView *view = nsView;
+
+ // 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
+ // that we can match the requested capabilities and leave the
+ // selection up to the built-in pixel format selection algorithm.
+ GLuint attribs[] = {
+ NSOpenGLPFANoRecovery,
+ NSOpenGLPFAWindow,
+ NSOpenGLPFAAccelerated,
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAColorSize, 32,
+ NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFADepthSize, 24,
+ NSOpenGLPFAStencilSize, 8,
+ NSOpenGLPFAAccumSize, 0,
+ 0
+ };
+
+ NSRect rect = [view frame];
+
+ NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) attribs];
+
+ NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat: [fmt autorelease] shareContext: nil];
+
+ if (view != nil) {
+ [context setView: view];
+
+ [context makeCurrentContext];
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ [context update];
+ [context flushBuffer];
+ }
+
+ return context;
+}
+
+Bool makeCurrentContext(void* nsView, void* nsContext) {
+ NSOpenGLContext *context = nsContext;
+
+ [context makeCurrentContext];
+ return true;
+}
+
+Bool clearCurrentContext(void* nsView, void* nsContext) {
+ NSView *view = nsView;
+ NSOpenGLContext *context = nsContext;
+
+ [NSOpenGLContext clearCurrentContext];
+ return true;
+}
+
+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;
+}
+
+Bool flushBuffer(void* nsView, void* nsContext) {
+ NSOpenGLContext *context = nsContext;
+
+ [context flushBuffer];
+ return true;
+}
+
+
+#include <mach-o/dyld.h>
+void* getProcAddress(const char *procname) {
+ void *funcPtr = NULL;
+ static char underscoreName[256];
+ strcpy(underscoreName, "_");
+ strcat(underscoreName, procname);
+ if (NSIsSymbolNameDefined(underscoreName)) {
+ NSSymbol sym = NSLookupAndBindSymbol(underscoreName);
+ funcPtr = (void *)NSAddressOfSymbol(sym);
+ }
+ return funcPtr;
+}