aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/cgl-macosx.cfg14
-rw-r--r--make/stub_includes/macosx/window-system.c15
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m68
-rw-r--r--src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java15
4 files changed, 61 insertions, 51 deletions
diff --git a/make/cgl-macosx.cfg b/make/cgl-macosx.cfg
index 6592f98dd..a933b36d9 100644
--- a/make/cgl-macosx.cfg
+++ b/make/cgl-macosx.cfg
@@ -13,7 +13,19 @@ Opaque long void *
# this was the easiest way of sharing the prototypes between these files
CustomCCode typedef int Bool;
-CustomCCode extern void* createContext(JNIEnv * env, jobject glCapabilities, void* shareContext, void* nsView);
+CustomCCode extern void* createContext(void* shareContext, void* nsView,
+CustomCCode int redBits,
+CustomCCode int greenBits,
+CustomCCode int blueBits,
+CustomCCode int alphaBits,
+CustomCCode int depthBits,
+CustomCCode int stencilBits,
+CustomCCode int accumRedBits,
+CustomCCode int accumGreenBits,
+CustomCCode int accumBlueBits,
+CustomCCode int accumAlphaBits,
+CustomCCode int sampleBuffers,
+CustomCCode int numSamples);
CustomCCode extern Bool makeCurrentContext(void* nsContext, void* nsView);
CustomCCode extern Bool clearCurrentContext(void* nsContext, void* nsView);
CustomCCode extern Bool deleteContext(void* nsContext, void* nsView);
diff --git a/make/stub_includes/macosx/window-system.c b/make/stub_includes/macosx/window-system.c
index 5b1381792..2908b07be 100644
--- a/make/stub_includes/macosx/window-system.c
+++ b/make/stub_includes/macosx/window-system.c
@@ -1,10 +1,21 @@
/* C routines encapsulating small amounts of Objective C code to allow
nsContext creation and manipulation to occur from Java */
-#include <jni.h>
typedef int Bool;
-void* createContext(JNIEnv* env, jobject glCapabilities, void* shareContext, void* nsView);
+void* createContext(void* shareContext, void* nsView,
+ int redBits,
+ int greenBits,
+ int blueBits,
+ int alphaBits,
+ int depthBits,
+ int stencilBits,
+ int accumRedBits,
+ int accumGreenBits,
+ int accumBlueBits,
+ int accumAlphaBits,
+ int sampleBuffers,
+ int numSamples);
Bool makeCurrentContext(void* nsContext, void* nsView);
Bool clearCurrentContext(void* nsContext, void* nsView);
Bool deleteContext(void* nsContext, void* nsView);
diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m
index 3d2269a31..7d2f317c9 100644
--- a/src/native/jogl/MacOSXWindowSystemInterface.m
+++ b/src/native/jogl/MacOSXWindowSystemInterface.m
@@ -16,45 +16,23 @@ typedef int Bool;
NSAutoreleasePool* gAutoreleasePool = NULL;
-void* createContext( JNIEnv* env, jobject glCapabilities, void* shareContext, void* view)
+void* createContext(void* shareContext, void* view,
+ int redBits,
+ int greenBits,
+ int blueBits,
+ int alphaBits,
+ int depthBits,
+ int stencilBits,
+ int accumRedBits,
+ int accumGreenBits,
+ int accumBlueBits,
+ int accumAlphaBits,
+ int sampleBuffers,
+ int numSamples)
{
- // fprintf( stderr, "Creating context \n");
-
- jclass clazz = (*env)->GetObjectClass( env, glCapabilities );
-
-
- jfieldID redSizeField = (*env)->GetFieldID( env, clazz, "redBits" , "I" );
- jfieldID greenSizeField = (*env)->GetFieldID( env, clazz, "greenBits" , "I" );
- jfieldID blueSizeField = (*env)->GetFieldID( env, clazz, "blueBits" , "I" );
-
- jfieldID alphaSizeField = (*env)->GetFieldID( env, clazz, "alphaBits", "I" );
- jfieldID depthSizeField = (*env)->GetFieldID( env, clazz, "depthBits", "I" );
- jfieldID stencilSizeField = (*env)->GetFieldID( env, clazz, "stencilBits", "I" );
- jfieldID accumRedSizeField = (*env)->GetFieldID( env, clazz, "accumRedBits", "I" );
- jfieldID accumGreenSizeField = (*env)->GetFieldID( env, clazz, "accumGreenBits", "I" );
- jfieldID accumBlueSizeField = (*env)->GetFieldID( env, clazz, "accumBlueBits", "I" );
- jfieldID accumAlphaSizeField = (*env)->GetFieldID( env, clazz, "accumAlphaBits", "I" );
-
- jint redSize = (*env)->GetIntField( env, glCapabilities, redSizeField );
- jint greenSize = (*env)->GetIntField( env, glCapabilities, greenSizeField );
- jint blueSize = (*env)->GetIntField( env, glCapabilities, blueSizeField );
- jint colorSize = redSize + greenSize + blueSize;
-
- jint accumRedSize = (*env)->GetIntField( env, glCapabilities, accumRedSizeField );
- jint accumGreenSize = (*env)->GetIntField( env, glCapabilities, accumGreenSizeField );
- jint accumBlueSize = (*env)->GetIntField( env, glCapabilities, accumBlueSizeField );
- jint accumAlphaSize = (*env)->GetIntField( env, glCapabilities, accumAlphaSizeField );
- jint accumSize = accumRedSize + accumGreenSize + accumBlueSize + accumAlphaSize;
-
-
- jint alphaSize = (*env)->GetIntField( env, glCapabilities, alphaSizeField );
- jint depthSize = (*env)->GetIntField( env, glCapabilities, depthSizeField );
- jint stencilSize = (*env)->GetIntField( env, glCapabilities, stencilSizeField );
-
- // fprintf(stderr, "Color %d, alpha %d, depth %d, stencil %d, accum %d", colorSize, alphaSize, depthSize, stencilSize, accumSize );
-
-
-//fprintf(stderr, "createContext shareContext=%p view=%p\n", shareContext, view);
+ int colorSize = redBits + greenBits + blueBits;
+ int accumSize = accumRedBits + accumGreenBits + accumBlueBits;
+
NSOpenGLContext *nsChareCtx = (NSOpenGLContext*)shareContext;
NSView *nsView = (NSView*)view;
@@ -80,22 +58,18 @@ void* createContext( JNIEnv* env, jobject glCapabilities, void* shareContext, vo
gAutoreleasePool = [[NSAutoreleasePool alloc] init];
}
- // 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.
-
NSOpenGLPixelFormatAttribute attribs[] =
{
NSOpenGLPFANoRecovery, YES,
NSOpenGLPFAAccelerated, YES,
NSOpenGLPFADoubleBuffer, YES,
NSOpenGLPFAColorSize, colorSize,
- NSOpenGLPFAAlphaSize, alphaSize,
- NSOpenGLPFADepthSize, depthSize,
- NSOpenGLPFAStencilSize, stencilSize,
+ NSOpenGLPFAAlphaSize, alphaBits,
+ NSOpenGLPFADepthSize, depthBits,
+ NSOpenGLPFAStencilSize, stencilBits,
NSOpenGLPFAAccumSize, accumSize,
+ NSOpenGLPFASampleBuffers, sampleBuffers,
+ NSOpenGLPFASamples, numSamples,
0
};
diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
index 470fe631d..2a34709f2 100644
--- a/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXGLContext.java
@@ -122,7 +122,20 @@ public abstract class MacOSXGLContext extends GLContext
throw new GLException("GLContextShareSet returned an invalid OpenGL context");
}
}
- nsContext = CGL.createContext( capabilities, share, nsView);
+ nsContext = CGL.createContext(share,
+ nsView,
+ capabilities.getRedBits(),
+ capabilities.getGreenBits(),
+ capabilities.getBlueBits(),
+ capabilities.getAlphaBits(),
+ capabilities.getDepthBits(),
+ capabilities.getStencilBits(),
+ capabilities.getAccumRedBits(),
+ capabilities.getAccumGreenBits(),
+ capabilities.getAccumBlueBits(),
+ capabilities.getAccumAlphaBits(),
+ capabilities.getSampleBuffers() ? 1 : 0,
+ capabilities.getNumSamples());
if (nsContext == 0) {
throw new GLException("Error creating nsContext");
}