apply CL/GL interop patch for mac, thx to jaekwon for patch.
This commit is contained in:
parent
ca428342d3
commit
a6fafde5e3
|
@ -36,6 +36,7 @@ import org.lwjgl.LWJGLUtil;
|
|||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.opencl.KHRGLSharing;
|
||||
import org.lwjgl.opencl.APPLEGLSharing;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
@ -275,8 +276,16 @@ final class ContextGL implements Context {
|
|||
properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(implLinux.getGLXContext(handle));
|
||||
properties.put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(implLinux.getDisplay(peer_handle));
|
||||
break;
|
||||
case LWJGLUtil.PLATFORM_MACOSX:
|
||||
if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 6)) { // only supported on OS X 10.6+
|
||||
// http://oscarbg.blogspot.com/2009/10/about-opencl-opengl-interop.html
|
||||
final MacOSXContextImplementation implMacOSX = (MacOSXContextImplementation)implementation;
|
||||
final long CGLShareGroup = implMacOSX.getCGLShareGroup(handle);
|
||||
properties.put(APPLEGLSharing.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(CGLShareGroup);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new UnsupportedOperationException("CL/GL context sharing is not supposed on this platform.");
|
||||
throw new UnsupportedOperationException("CL/GL context sharing is not supported on this platform.");
|
||||
}
|
||||
} finally {
|
||||
peer_info.unlock();
|
||||
|
|
|
@ -63,6 +63,8 @@ final class MacOSXContextImplementation implements ContextImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
native long getCGLShareGroup(ByteBuffer context_handle);
|
||||
|
||||
private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException;
|
||||
|
||||
public void update(ByteBuffer context_handle) {
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
*/
|
||||
|
||||
#import <jni.h>
|
||||
#import <OpenGL/CGLCurrent.h>
|
||||
#import <OpenGL/CGLTypes.h>
|
||||
#import <OpenGL/CGLDevice.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "org_lwjgl_opengl_MacOSXContextImplementation.h"
|
||||
#import "context.h"
|
||||
|
@ -78,6 +81,16 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCre
|
|||
return context_handle;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_getCGLShareGroup
|
||||
(JNIEnv *env, jclass clazz, jobject context_handle) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
MacOSXContext *context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);
|
||||
CGLContextObj cgl_context = [context_info->context CGLContextObj];
|
||||
CGLShareGroupObj share_group = CGLGetShareGroup(cgl_context);
|
||||
[pool release];
|
||||
return share_group;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nSwapBuffers
|
||||
(JNIEnv *env, jclass clazz, jobject context_handle) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
|
Loading…
Reference in New Issue