diff options
author | Michael Bien <[email protected]> | 2010-06-10 14:28:03 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-06-10 14:28:03 +0200 |
commit | 2522d4f1ebffec030d7e8c3688e5f952c574c3d0 (patch) | |
tree | 81d631cb11dadc483a4615996dedf773eed083da /make/config | |
parent | 57d3d3f9f9475ae167cd9d33c9450eea66439fd2 (diff) | |
parent | 1d333a771ce0bc7c8594e21d031703f698f06a46 (diff) |
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'make/config')
30 files changed, 262 insertions, 503 deletions
diff --git a/make/config/jogl/cg-common-CustomJavaCode.java b/make/config/jogl/cg-common-CustomJavaCode.java index d1e4f8bf5..cdaa6f2b2 100755 --- a/make/config/jogl/cg-common-CustomJavaCode.java +++ b/make/config/jogl/cg-common-CustomJavaCode.java @@ -1,7 +1,26 @@ +private static DynamicLookupHelper cgDynamicLookupHelper; +private static CgProcAddressTable cgProcAddressTable; + static { - com.jogamp.opengl.impl.GLJNILibLoader.loadCgImpl(); + cgProcAddressTable = new CgProcAddressTable(); + if(null==cgProcAddressTable) { + throw new RuntimeException("Couldn't instantiate CgProcAddressTable"); + } + DynamicLibraryBundle cgDynamicLookupHelper = new DynamicLibraryBundle(new CgDynamicLibraryBundleInfo()); + if(null==cgDynamicLookupHelper) { + throw new RuntimeException("Null CgDynamicLookupHelper"); + } + if(!cgDynamicLookupHelper.isToolLibLoaded()) { + throw new RuntimeException("Couln't load native Cg or CgGL library"); + } + if(!cgDynamicLookupHelper.isGlueLibLoaded(CgDynamicLibraryBundleInfo.getCgGlueLibIndex())) { + throw new RuntimeException("Couln't load native GLue/JNI library"); + } + cgProcAddressTable.reset(cgDynamicLookupHelper); } +public static CgProcAddressTable getCgProcAddressTable() { return cgProcAddressTable; } + /** A convenience method which reads all available data from the InputStream and then calls cgCreateProgram. */ public static CGprogram cgCreateProgramFromStream(CGcontext ctx, int program_type, java.io.InputStream stream, int profile, java.lang.String entry, java.lang.String[] args) throws java.io.IOException { if (stream == null) { diff --git a/make/config/jogl/cg-common.cfg b/make/config/jogl/cg-common.cfg index 927d233a8..ae29d3f80 100644 --- a/make/config/jogl/cg-common.cfg +++ b/make/config/jogl/cg-common.cfg @@ -7,6 +7,14 @@ JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl_cg HierarchicalNativeOutput false +ForceProcAddressGen __ALL__ +LocalProcAddressCallingConvention __ALL__ APIENTRY + +EmitProcAddressTable true +ProcAddressTableClassName CgProcAddressTable +GetProcAddressTableExpr cgProcAddressTable +ProcAddressNameExpr PFN $UPPERCASE({0}) PROC + # # Map const char* return values to Java strings for these functions # @@ -94,6 +102,9 @@ Ignore cgGetProgramOptions # And NativeLibLoader for help loading the native libraries Import com.jogamp.opengl.impl.* +Import com.jogamp.common.os.DynamicLookupHelper; +Import com.jogamp.common.os.DynamicLibraryBundle; +Import com.jogamp.opengl.cg.CgDynamicLibraryBundleInfo; # # NIODirectOnly directives for routines requiring them for semantic reasons diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg index f2af29e00..2b28d3c68 100644 --- a/make/config/jogl/cgl-macosx.cfg +++ b/make/config/jogl/cgl-macosx.cfg @@ -5,7 +5,7 @@ NativeOutputDir gensrc/native/jogl/MacOSX Package com.jogamp.opengl.impl.macosx.cgl JavaClass CGL -Style allstatic +Style AllStatic Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg diff --git a/make/config/jogl/egl.cfg b/make/config/jogl/egl.cfg index 94984a305..c194de2d0 100755 --- a/make/config/jogl/egl.cfg +++ b/make/config/jogl/egl.cfg @@ -5,7 +5,7 @@ NativeOutputDir gensrc/native/jogl/egl Package com.jogamp.opengl.impl.egl JavaClass EGL -Style allstatic +Style AllStatic # Shouldn't matter which one of these we pick up Include egl-common.cfg diff --git a/make/config/jogl/wgl-CustomCCode.c b/make/config/jogl/gdi-CustomCCode.c index 0fe9ee628..0fe9ee628 100755 --- a/make/config/jogl/wgl-CustomCCode.c +++ b/make/config/jogl/gdi-CustomCCode.c diff --git a/make/config/jogl/gdi-win32.cfg b/make/config/jogl/gdi-win32.cfg new file mode 100644 index 000000000..7d831c7b9 --- /dev/null +++ b/make/config/jogl/gdi-win32.cfg @@ -0,0 +1,26 @@ +# This .cfg file is used to generate the interface to the wgl routines +# used internally by the WindowsGLContext implementation. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/Windows + +Package com.jogamp.opengl.impl.windows.wgl +JavaClass GDI +Style AllStatic +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl-desktop.cfg + +GLHeader wingdi.h + +AllowNonGLExtensions true + +CustomCCode #define WIN32_LEAN_AND_MEAN +CustomCCode #include <windows.h> +CustomCCode #undef WIN32_LEAN_AND_MEAN + +CustomCCode #include <wingdi.h> +CustomCCode #include <stddef.h> + +Include ../intptr.cfg + +IncludeAs CustomCCode gdi-CustomCCode.c diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 8d726c4bf..2c8e79e75 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -39,6 +39,7 @@ Ignore glTracePointerRangeMESA # Manually implement glMapBuffer as the size of the returned buffer # can only be computed by calling another routine ManuallyImplement glMapBuffer +ForceProcAddressGen glMapBuffer # Ignore the ATI_map_object_buffer extension for now unless someone # claims they need it, as it will undoubtedly require a similar @@ -347,6 +348,8 @@ NIODirectOnly glXFreeMemoryNV ReturnValueCapacity wglAllocateMemoryNV {0} ReturnValueCapacity glXAllocateMemoryNV {0} +ReturnValueCapacity glMapBufferRange {2} + # Pass arguments to ARB_vertex_program, ARB_fragment_program, # ARB_shader_objects, NV_vertex_program, NV_fragment_program, and # ARB_vertex_shader as Strings diff --git a/make/config/jogl/gl-desktop.cfg b/make/config/jogl/gl-desktop.cfg index f35ed254b..ce2fefe2f 100755 --- a/make/config/jogl/gl-desktop.cfg +++ b/make/config/jogl/gl-desktop.cfg @@ -51,19 +51,11 @@ Opaque long Visual * # traversed) Ignore Display Ignore Visual -# Implement the first argument to glXGetProcAddress as String instead -# of byte[] ArgumentIsString glXGetProcAddress 0 ArgumentIsString glXGetProcAddressARB 0 ReturnsString glXQueryExtensionsString ReturnsString glXQueryServerString ReturnsString glXGetClientString -TemporaryCVariableDeclaration glXChooseFBConfig int count; -TemporaryCVariableAssignment glXChooseFBConfig count = _ptr3[0]; -ReturnValueCapacity glXChooseFBConfig count * sizeof(GLXFBConfig) -TemporaryCVariableDeclaration glXChooseFBConfigSGIX int count; -TemporaryCVariableAssignment glXChooseFBConfigSGIX count = _ptr3[0]; -ReturnValueCapacity glXChooseFBConfigSGIX count * sizeof(GLXFBConfig) TemporaryCVariableDeclaration glXGetFBConfigs int count; TemporaryCVariableAssignment glXGetFBConfigs count = _nelements_ptr[0]; ReturnValueCapacity glXGetFBConfigs count * sizeof(GLXFBConfig) diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg index da2267186..63905dfff 100755 --- a/make/config/jogl/gl-es1.cfg +++ b/make/config/jogl/gl-es1.cfg @@ -97,4 +97,4 @@ IncludeAs CustomCCode gl-impl-CustomCCode-gles1.c Import javax.media.opengl.GLES1 Import javax.media.opengl.GLES2 Import javax.media.opengl.GL2 -Import com.jogamp.opengl.impl.InternalBufferUtil +Import com.jogamp.common.nio.Buffers; diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg index fd11ffcf0..cdfd7fef8 100755 --- a/make/config/jogl/gl-es2.cfg +++ b/make/config/jogl/gl-es2.cfg @@ -79,6 +79,6 @@ Import javax.media.opengl.GLES2 Import javax.media.opengl.GL2 Import javax.media.opengl.GLArrayData Import javax.media.opengl.GLUniformData -Import com.jogamp.opengl.impl.InternalBufferUtil +Import com.jogamp.common.nio.Buffers; Import java.io.PrintStream diff --git a/make/config/jogl/gl-gl2es12.cfg b/make/config/jogl/gl-gl2es12.cfg index 3942b1419..ec121d777 100644 --- a/make/config/jogl/gl-gl2es12.cfg +++ b/make/config/jogl/gl-gl2es12.cfg @@ -22,11 +22,6 @@ Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg -# Because we're manually implementing glMapBuffer but only producing -# the implementing class, GlueGen doesn't notice that it has to emit a -# proc address table entry for it. Force it to here. -ForceProcAddressGen glMapBuffer - # Force all of the methods to be emitted using dynamic linking so we # don't need to link against any emulation library on the desktop or # depend on the presence of an import library for a particular device @@ -86,5 +81,5 @@ IncludeAs CustomCCode gl-impl-CustomCCode-gl2es12.c Import javax.media.opengl.GLES1 Import javax.media.opengl.GLES2 -Import com.jogamp.opengl.impl.InternalBufferUtil +Import com.jogamp.common.nio.Buffers; Import java.io.PrintStream diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg index 3a3e02041..ccd9723e6 100644 --- a/make/config/jogl/gl-gl4bc.cfg +++ b/make/config/jogl/gl-gl4bc.cfg @@ -46,10 +46,11 @@ Include gl3-common.cfg Include gl4-common.cfg Include gl3-desktop.cfg -# Because we're manually implementing glMapBuffer but only producing -# the implementing class, GlueGen doesn't notice that it has to emit a -# proc address table entry for it. Force it to here. -ForceProcAddressGen glMapBuffer +# Manually implement glMapNamedBufferEXT as the size of the returned buffer +# can only be computed by calling another routine +ManuallyImplement glMapNamedBufferEXT +ForceProcAddressGen glMapNamedBufferEXT +JavaEpilogue glNamedBufferDataEXT bufferSizeTracker.setDirectStateBufferSize({0}, this, {1}); # Force all of the methods to be emitted using dynamic linking so we # don't need to link against any emulation library on the desktop or @@ -106,5 +107,5 @@ Import javax.media.opengl.GL2 Import javax.media.opengl.GL3 Import javax.media.opengl.GL3bc Import javax.media.opengl.GL4 -Import com.jogamp.opengl.impl.InternalBufferUtil +Import com.jogamp.common.nio.Buffers; Import java.io.PrintStream diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c index bcda20fa4..0bd8b68da 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -15,6 +15,21 @@ Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_dispatch_1glMapBuffer(JNIEnv *env, job /* Java->C glue code: * Java package: com.jogamp.opengl.impl.gl4.GL4bcImpl + * Java method: long dispatch_glMapNamedBufferEXT(int target, int access) + * C function: void * glMapNamedBufferEXT(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferEXT(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { + PFNGLMAPNAMEDBUFFEREXTPROC ptr_glMapNamedBufferEXT; + void * _res; + ptr_glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC) (intptr_t) glProcAddress; + assert(ptr_glMapNamedBufferEXT != NULL); + _res = (* ptr_glMapNamedBufferEXT) ((GLenum) target, (GLenum) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl4.GL4bcImpl * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); */ diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java index 4bc39b076..cb0d01312 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java @@ -339,16 +339,19 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } long addr; addr = dispatch_glMapBuffer(target, access, __addr_); - if (addr == 0 || sz == 0) { + if (0 == addr) { return null; } ARBVBOKey key = new ARBVBOKey(addr, sz); ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key); if (_res == null) { _res = newDirectByteBuffer(addr, sz); - InternalBufferUtil.nativeOrder(_res); + Buffers.nativeOrder(_res); arbVBOCache.put(key, _res); } _res.position(0); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4.java deleted file mode 100644 index a2c70eeee..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4.java +++ /dev/null @@ -1,339 +0,0 @@ -// Tracks glBegin/glEnd calls to determine whether it is legal to -// query Vertex Buffer Object state -private boolean inBeginEndPair; - -/* FIXME: refactor dependence on Java 2D / JOGL bridge - -// Tracks creation and destruction of server-side OpenGL objects when -// the Java2D/OpenGL pipeline is enabled and it is using frame buffer -// objects (FBOs) to do its rendering -private GLObjectTracker tracker; - -public void setObjectTracker(GLObjectTracker tracker) { - this.tracker = tracker; -} - -*/ - -public GL3Impl(GLProfile glp, GLContextImpl context) { - this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - this.glProfile = glp; -} - -/** - * Provides platform-independent access to the wglAllocateMemoryNV / - * glXAllocateMemoryNV extension. - */ -public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3); -} - -// -// Helpers for ensuring the correct amount of texture data -// - -/** Returns the number of bytes required to fill in the appropriate - texture. This is computed as closely as possible based on the - pixel pack or unpack parameters. The logic in this routine is - based on code in the SGI OpenGL sample implementation. */ - -private int imageSizeInBytes(int format, int type, int w, int h, int d, - boolean pack) { - int elements = 0; - int esize = 0; - - if (w < 0) return 0; - if (h < 0) return 0; - if (d < 0) return 0; - switch (format) { - case GL_STENCIL_INDEX: - elements = 1; - break; - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_DEPTH_COMPONENT: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - case GL_BGR: - elements = 3; - break; - case GL_RGBA: - case GL_BGRA: - elements = 4; - break; - /* FIXME ?? - case GL_HILO_NV: - elements = 2; - break; */ - default: - return 0; - } - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - esize = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - esize = 1; - elements = 1; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - break; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - esize = 4; - elements = 1; - break; - default: - return 0; - } - return imageSizeInBytes(elements * esize, w, h, d, pack); -} - -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; - -private boolean bufferObjectExtensionsInitialized = false; -private boolean haveARBPixelBufferObject; -private boolean haveEXTPixelBufferObject; -private boolean haveGL15; -private boolean haveGL21; -private boolean haveARBVertexBufferObject; - -private void initBufferObjectExtensionChecks() { - if (bufferObjectExtensionsInitialized) - return; - bufferObjectExtensionsInitialized = true; - haveARBPixelBufferObject = isExtensionAvailable("GL_ARB_pixel_buffer_object"); - haveEXTPixelBufferObject = isExtensionAvailable("GL_EXT_pixel_buffer_object"); - haveGL15 = isExtensionAvailable("GL_VERSION_1_5"); - haveGL21 = isExtensionAvailable("GL_VERSION_2_1"); - haveARBVertexBufferObject = isExtensionAvailable("GL_ARB_vertex_buffer_object"); -} - -private boolean checkBufferObject(boolean extension1, - boolean extension2, - boolean extension3, - boolean enabled, - int state, - String kind, boolean throwException) { - if (inBeginEndPair) { - throw new GLException("May not call this between glBegin and glEnd"); - } - boolean avail = (extension1 || extension2 || extension3); - if (!avail) { - if (!enabled) - return true; - if(throwException) { - throw new GLException("Required extensions not available to call this function"); - } - return false; - } - int buffer = bufferStateTracker.getBoundBufferObject(state, this); - if (enabled) { - if (buffer == 0) { - if(throwException) { - throw new GLException(kind + " must be enabled to call this method"); - } - return false; - } - } else { - if (buffer != 0) { - if(throwException) { - throw new GLException(kind + " must be disabled to call this method"); - } - return false; - } - } - return true; -} - -private boolean checkArrayVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - false, - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private boolean checkArrayVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - true, - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private boolean checkElementVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - false, - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private boolean checkElementVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveGL15, - haveARBVertexBufferObject, - false, - true, - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private boolean checkUnpackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveARBPixelBufferObject, - haveEXTPixelBufferObject, - haveGL21, - false, - GL2.GL_PIXEL_UNPACK_BUFFER, - "unpack pixel_buffer_object", throwException); -} - -private boolean checkUnpackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveARBPixelBufferObject, - haveEXTPixelBufferObject, - haveGL21, - true, - GL2.GL_PIXEL_UNPACK_BUFFER, - "unpack pixel_buffer_object", throwException); -} - -private boolean checkPackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveARBPixelBufferObject, - haveEXTPixelBufferObject, - haveGL21, - false, - GL2.GL_PIXEL_PACK_BUFFER, - "pack pixel_buffer_object", throwException); -} - -private boolean checkPackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); - return checkBufferObject(haveARBPixelBufferObject, - haveEXTPixelBufferObject, - haveGL21, - true, - GL2.GL_PIXEL_PACK_BUFFER, - "pack pixel_buffer_object", throwException); -} - -public boolean glIsPBOPackEnabled() { - return checkPackPBOEnabled(false); -} - -public boolean glIsPBOUnpackEnabled() { - return checkUnpackPBOEnabled(false); -} - -// Attempt to return the same ByteBuffer object from glMapBuffer if -// the vertex buffer object's base address and size haven't changed -private static class ARBVBOKey { - private long addr; - private int capacity; - - ARBVBOKey(long addr, int capacity) { - this.addr = addr; - this.capacity = capacity; - } - - public int hashCode() { - return (int) addr; - } - - public boolean equals(Object o) { - if ((o == null) || (!(o instanceof ARBVBOKey))) { - return false; - } - - ARBVBOKey other = (ARBVBOKey) o; - return ((addr == other.addr) && (capacity == other.capacity)); - } -} - -private Map/*<ARBVBOKey, ByteBuffer>*/ arbVBOCache = new HashMap(); - -/** Entry point to C language function: <br> <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ -public java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GL3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; - if (__addr_ == 0) { - throw new GLException("Method \"glMapBuffer\" not available"); - } - int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, - target, - this); - long addr; - addr = dispatch_glMapBuffer(target, access, __addr_); - if (addr == 0 || sz == 0) { - return null; - } - ARBVBOKey key = new ARBVBOKey(addr, sz); - ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key); - if (_res == null) { - _res = newDirectByteBuffer(addr, sz); - InternalBufferUtil.nativeOrder(_res); - arbVBOCache.put(key, _res); - } - _res.position(0); - return _res; -} - -/** Encapsulates function pointer for OpenGL function <br>: <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ -native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); - -native private ByteBuffer newDirectByteBuffer(long addr, int capacity); - - /** Dummy implementation for the ES 2.0 function: <br> <code> void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length); </code> <br> Always throws a GLException! */ - public void glShaderBinary(int n, java.nio.IntBuffer shaders, int binaryformat, java.nio.Buffer binary, int length) { - throw new GLException("Method \"glShaderBinary\" not available"); - } - - /** Dummy implementation for the ES 2.0 function: <br> <code> void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length); </code> <br> Always throws a GLException! */ - public void glShaderBinary(int n, int[] shaders, int shaders_offset, int binaryformat, java.nio.Buffer binary, int length) { - throw new GLException("Method \"glShaderBinary\" not available"); - } - - public void glReleaseShaderCompiler() { - // nothing to do - } - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index bceb12fe5..aa176738a 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -308,19 +308,20 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { if (__addr_ == 0) { throw new GLException("Method \"glMapBuffer\" not available"); } - int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, - target, - this); + int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } long addr; addr = dispatch_glMapBuffer(target, access, __addr_); - if (addr == 0 || sz == 0) { + if (0 == addr) { return null; } ARBVBOKey key = new ARBVBOKey(addr, sz); ByteBuffer _res = (ByteBuffer) arbVBOCache.get(key); if (_res == null) { _res = newDirectByteBuffer(addr, sz); - InternalBufferUtil.nativeOrder(_res); + Buffers.nativeOrder(_res); arbVBOCache.put(key, _res); } _res.position(0); @@ -330,6 +331,29 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { /** Encapsulates function pointer for OpenGL function <br>: <code> LPVOID glMapBuffer(GLenum target, GLenum access); </code> */ native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); +/** Entry point to C language function: <code> GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access); </code> <br>Part of <code>GL_EXT_direct_state_access</code> */ +public java.nio.ByteBuffer glMapNamedBufferEXT(int buffer, int access) { + final long __addr_ = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT; + if (__addr_ == 0) { + throw new GLException("Method \"glMapNamedBufferEXT\" not available"); + } + int sz = bufferSizeTracker.getDirectStateBufferSize(buffer, this); + if (0 == sz) { + return null; + } + long addr; + addr = dispatch_glMapNamedBufferEXT(buffer, access, __addr_); + if (0 == addr) { + return null; + } + ByteBuffer _res = newDirectByteBuffer(addr, sz); + Buffers.nativeOrder(_res); + _res.position(0); + return _res; +} + +private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); + native private ByteBuffer newDirectByteBuffer(long addr, int capacity); /** Dummy implementation for the ES 2.0 function: <br> <code> void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length); </code> <br> Always throws a GLException! */ diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index b4efac8a1..d29fe1645 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -285,16 +285,19 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } long addr; addr = dispatch_glMapBuffer(target, access, __addr_); - if (addr == 0 || sz == 0) { + if (0 == addr) { return null; } ARBVBOKey key = new ARBVBOKey(addr, sz); java.nio.ByteBuffer _res = (java.nio.ByteBuffer) arbVBOCache.get(key); if (_res == null) { _res = newDirectByteBuffer(addr, sz); - InternalBufferUtil.nativeOrder(_res); + Buffers.nativeOrder(_res); arbVBOCache.put(key, _res); } _res.position(0); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index bb8ddb7ef..e65c491a2 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -295,16 +295,19 @@ public java.nio.ByteBuffer glMapBuffer(int target, int access) { int sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } long addr; addr = dispatch_glMapBuffer(target, access, __addr_); - if (addr == 0 || sz == 0) { + if (0 == addr) { return null; } ARBVBOKey key = new ARBVBOKey(addr, sz); java.nio.ByteBuffer _res = (java.nio.ByteBuffer) arbVBOCache.get(key); if (_res == null) { _res = newDirectByteBuffer(addr, sz); - InternalBufferUtil.nativeOrder(_res); + Buffers.nativeOrder(_res); arbVBOCache.put(key, _res); } _res.position(0); diff --git a/make/config/jogl/gl3-desktop.cfg b/make/config/jogl/gl3-desktop.cfg index ee741089e..19eef4270 100755 --- a/make/config/jogl/gl3-desktop.cfg +++ b/make/config/jogl/gl3-desktop.cfg @@ -47,19 +47,11 @@ Opaque long Visual * # traversed) Ignore Display Ignore Visual -# Implement the first argument to glXGetProcAddress as String instead -# of byte[] ArgumentIsString glXGetProcAddress 0 ArgumentIsString glXGetProcAddressARB 0 ReturnsString glXQueryExtensionsString ReturnsString glXQueryServerString ReturnsString glXGetClientString -TemporaryCVariableDeclaration glXChooseFBConfig int count; -TemporaryCVariableAssignment glXChooseFBConfig count = _ptr3[0]; -ReturnValueCapacity glXChooseFBConfig count * sizeof(GLXFBConfig) -TemporaryCVariableDeclaration glXChooseFBConfigSGIX int count; -TemporaryCVariableAssignment glXChooseFBConfigSGIX count = _ptr3[0]; -ReturnValueCapacity glXChooseFBConfigSGIX count * sizeof(GLXFBConfig) TemporaryCVariableDeclaration glXGetFBConfigs int count; TemporaryCVariableAssignment glXGetFBConfigs count = _nelements_ptr[0]; ReturnValueCapacity glXGetFBConfigs count * sizeof(GLXFBConfig) diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java index 480f5d117..7aee33ae1 100755 --- a/make/config/jogl/glu-CustomJavaCode-base.java +++ b/make/config/jogl/glu-CustomJavaCode-base.java @@ -1382,21 +1382,21 @@ public void gluLookAt(double eyeX, double eyeY, double eyeZ, double centerX, dou * <P> Accepts the outgoing window coordinates as a single array. */ public boolean gluProject(double objX, double objY, double objZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] winPos, int winPos_offset) { - return project.gluProject((float)objX, (float)objY, (float)objZ, InternalBufferUtil.getFloatArray(model), model_offset, InternalBufferUtil.getFloatArray(proj), proj_offset, view, view_offset, InternalBufferUtil.getFloatArray(winPos), winPos_offset); + return project.gluProject((float)objX, (float)objY, (float)objZ, Buffers.getFloatArray(model), model_offset, Buffers.getFloatArray(proj), proj_offset, view, view_offset, Buffers.getFloatArray(winPos), winPos_offset); } /** Interface to C language function: <br> <code> GLint gluUnProject(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * objX, GLdouble * objY, GLdouble * objZ); </code> * <P> Accepts the outgoing object coordinates (a 3-vector) as a single array. */ public boolean gluUnProject(double winX, double winY, double winZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] objPos, int objPos_offset) { - return project.gluUnProject((float)winX, (float)winY, (float)winZ, InternalBufferUtil.getFloatArray(model), model_offset, InternalBufferUtil.getFloatArray(proj), proj_offset, view, view_offset, InternalBufferUtil.getFloatArray(objPos), objPos_offset); + return project.gluUnProject((float)winX, (float)winY, (float)winZ, Buffers.getFloatArray(model), model_offset, Buffers.getFloatArray(proj), proj_offset, view, view_offset, Buffers.getFloatArray(objPos), objPos_offset); } /** Interface to C language function: <br> <code> GLint gluUnProject4(GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble nearVal, GLdouble farVal, GLdouble * objX, GLdouble * objY, GLdouble * objZ, GLdouble * objW); </code> * <P> Accepts the outgoing object coordinates (a 4-vector) as a single array. */ public boolean gluUnProject4(double winX, double winY, double winZ, double clipW, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double nearVal, double farVal, double[] objPos, int objPos_offset) { - return project.gluUnProject4((float)winX, (float)winY, (float)winZ, (float)clipW, InternalBufferUtil.getFloatArray(model), model_offset, InternalBufferUtil.getFloatArray(proj), proj_offset, view, view_offset, (float)nearVal, (float)farVal, InternalBufferUtil.getFloatArray(objPos), objPos_offset); + return project.gluUnProject4((float)winX, (float)winY, (float)winZ, (float)clipW, Buffers.getFloatArray(model), model_offset, Buffers.getFloatArray(proj), proj_offset, view, view_offset, (float)nearVal, (float)farVal, Buffers.getFloatArray(objPos), objPos_offset); } public void gluPickMatrix(double x, double y, double delX, double delY, int[] viewport, int viewport_offset) { diff --git a/make/config/jogl/glu-CustomJavaCode-gl2.java b/make/config/jogl/glu-CustomJavaCode-gl2.java index 690e0acfa..4dcb5691e 100644 --- a/make/config/jogl/glu-CustomJavaCode-gl2.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2.java @@ -218,13 +218,13 @@ private final ByteBuffer copyToByteBuffer(Buffer buf) { if (buf.position() == 0) { return (ByteBuffer) buf; } - return InternalBufferUtil.copyByteBuffer((ByteBuffer) buf); + return Buffers.copyByteBuffer((ByteBuffer) buf); } else if (buf instanceof ShortBuffer) { - return InternalBufferUtil.copyShortBufferAsByteBuffer((ShortBuffer) buf); + return Buffers.copyShortBufferAsByteBuffer((ShortBuffer) buf); } else if (buf instanceof IntBuffer) { - return InternalBufferUtil.copyIntBufferAsByteBuffer((IntBuffer) buf); + return Buffers.copyIntBufferAsByteBuffer((IntBuffer) buf); } else if (buf instanceof FloatBuffer) { - return InternalBufferUtil.copyFloatBufferAsByteBuffer((FloatBuffer) buf); + return Buffers.copyFloatBufferAsByteBuffer((FloatBuffer) buf); } else { throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)"); } @@ -239,11 +239,11 @@ private final int gluScaleImageJava( int format, int widthin, int heightin, if( dataout instanceof ByteBuffer ) { out = (ByteBuffer)dataout; } else if( dataout instanceof ShortBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_SHORT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_SHORT); } else if ( dataout instanceof IntBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_INT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_INT); } else if ( dataout instanceof FloatBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_FLOAT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_FLOAT); } else { throw new IllegalArgumentException("Unsupported destination buffer type (must be byte, short, int, or float)"); } @@ -536,27 +536,18 @@ public final void gluEndCurve(GLUnurbs r) { // private static GLUgl2ProcAddressTable gluProcAddressTable; -private static volatile boolean gluLibraryLoaded; private static final GLUgl2ProcAddressTable getGLUProcAddressTable() { - if (!gluLibraryLoaded) { - loadGLULibrary(); - } if (gluProcAddressTable == null) { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } + GLDynamicLookupHelper glLookupHelper = ((GLDrawableImpl) curContext.getGLDrawable()).getGLDynamicLookupHelper(); + glLookupHelper.loadGLULibrary(); GLUgl2ProcAddressTable tmp = new GLUgl2ProcAddressTable(new GLProcAddressResolver()); - tmp.reset(((GLDrawableImpl)curContext.getGLDrawable()).getDynamicLookupHelper()); + tmp.reset(glLookupHelper); gluProcAddressTable = tmp; } return gluProcAddressTable; } - -private static final synchronized void loadGLULibrary() { - if (!gluLibraryLoaded) { - GLDrawableFactoryImpl.getFactoryImpl(null).loadGLULibrary(); - gluLibraryLoaded = true; - } -} diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java index eb4bcc718..742f7c240 100755 --- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java @@ -99,13 +99,13 @@ private final java.nio.ByteBuffer copyToByteBuffer(java.nio.Buffer buf) { if (buf.position() == 0) { return (java.nio.ByteBuffer) buf; } - return InternalBufferUtil.copyByteBuffer((java.nio.ByteBuffer) buf); + return Buffers.copyByteBuffer((java.nio.ByteBuffer) buf); } else if (buf instanceof java.nio.ShortBuffer) { - return InternalBufferUtil.copyShortBufferAsByteBuffer((java.nio.ShortBuffer) buf); + return Buffers.copyShortBufferAsByteBuffer((java.nio.ShortBuffer) buf); } else if (buf instanceof java.nio.IntBuffer) { - return InternalBufferUtil.copyIntBufferAsByteBuffer((java.nio.IntBuffer) buf); + return Buffers.copyIntBufferAsByteBuffer((java.nio.IntBuffer) buf); } else if (buf instanceof java.nio.FloatBuffer) { - return InternalBufferUtil.copyFloatBufferAsByteBuffer((java.nio.FloatBuffer) buf); + return Buffers.copyFloatBufferAsByteBuffer((java.nio.FloatBuffer) buf); } else { throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)"); } @@ -124,11 +124,11 @@ public final int gluScaleImage( int format, int widthin, int heightin, if( dataout instanceof java.nio.ByteBuffer ) { out = (java.nio.ByteBuffer)dataout; } else if( dataout instanceof java.nio.ShortBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_SHORT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_SHORT); } else if ( dataout instanceof java.nio.IntBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_INT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_INT); } else if ( dataout instanceof java.nio.FloatBuffer ) { - out = InternalBufferUtil.newByteBuffer(dataout.remaining() * InternalBufferUtil.SIZEOF_FLOAT); + out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_FLOAT); } else { throw new IllegalArgumentException("Unsupported destination buffer type (must be byte, short, int, or float)"); } @@ -225,30 +225,3 @@ public final int gluBuild3DMipmaps( int target, int internalFormat, int width, depth, format, type, buffer ) ); } -//---------------------------------------------------------------------- -// GLUProcAddressTable handling -// - -/* -private static GLUProcAddressTable gluProcAddressTable; -private static volatile boolean gluLibraryLoaded; - -private static GLUProcAddressTable getGLUProcAddressTable() { - if (!gluLibraryLoaded) { - loadGLULibrary(); - } - if (gluProcAddressTable == null) { - GLUProcAddressTable tmp = new GLUProcAddressTable(new GLProcAddressResolver()); - tmp.reset(GLDrawableFactoryImpl.getFactoryImpl()); - gluProcAddressTable = tmp; - } - return gluProcAddressTable; -} - -private static synchronized void loadGLULibrary() { - if (!gluLibraryLoaded) { - GLDrawableFactoryImpl.getFactoryImpl().loadGLULibrary(); - gluLibraryLoaded = true; - } -} -*/ diff --git a/make/config/jogl/glx-CustomCCode.c b/make/config/jogl/glx-CustomCCode.c index 1b30a7da6..dec3f4583 100755 --- a/make/config/jogl/glx-CustomCCode.c +++ b/make/config/jogl/glx-CustomCCode.c @@ -15,28 +15,28 @@ /* We expect glXGetProcAddressARB to be defined */ extern void (*glXGetProcAddressARB(const GLubyte *procname))(); -static const char * clazzNameInternalBufferUtil = "com/jogamp/opengl/impl/InternalBufferUtil"; -static const char * clazzNameInternalBufferUtilStaticCstrName = "copyByteBuffer"; -static const char * clazzNameInternalBufferUtilStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; +static const char * clazzNameBuffers = "com/jogamp/common/nio/Buffers"; +static const char * clazzNameBuffersStaticCstrName = "copyByteBuffer"; +static const char * clazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; static const char * clazzNameByteBuffer = "java/nio/ByteBuffer"; -static jclass clazzInternalBufferUtil = NULL; -static jmethodID cstrInternalBufferUtil = NULL; +static jclass clazzBuffers = NULL; +static jmethodID cstrBuffers = NULL; static jclass clazzByteBuffer = NULL; static void _initClazzAccess(JNIEnv *env) { jclass c; - if(NULL!=cstrInternalBufferUtil) return ; + if(NULL!=cstrBuffers) return ; - c = (*env)->FindClass(env, clazzNameInternalBufferUtil); + c = (*env)->FindClass(env, clazzNameBuffers); if(NULL==c) { - fprintf(stderr, "FatalError: Java_com_jogamp_opengl_impl_x11_glx_GLX: can't find %s\n", clazzNameInternalBufferUtil); - (*env)->FatalError(env, clazzNameInternalBufferUtil); + fprintf(stderr, "FatalError: Java_com_jogamp_opengl_impl_x11_glx_GLX: can't find %s\n", clazzNameBuffers); + (*env)->FatalError(env, clazzNameBuffers); } - clazzInternalBufferUtil = (jclass)(*env)->NewGlobalRef(env, c); - if(NULL==clazzInternalBufferUtil) { - fprintf(stderr, "FatalError: Java_com_jogamp_opengl_impl_x11_glx_GLX: can't use %s\n", clazzNameInternalBufferUtil); - (*env)->FatalError(env, clazzNameInternalBufferUtil); + clazzBuffers = (jclass)(*env)->NewGlobalRef(env, c); + if(NULL==clazzBuffers) { + fprintf(stderr, "FatalError: Java_com_jogamp_opengl_impl_x11_glx_GLX: can't use %s\n", clazzNameBuffers); + (*env)->FatalError(env, clazzNameBuffers); } c = (*env)->FindClass(env, clazzNameByteBuffer); if(NULL==c) { @@ -49,13 +49,13 @@ static void _initClazzAccess(JNIEnv *env) { (*env)->FatalError(env, clazzNameByteBuffer); } - cstrInternalBufferUtil = (*env)->GetStaticMethodID(env, clazzInternalBufferUtil, - clazzNameInternalBufferUtilStaticCstrName, clazzNameInternalBufferUtilStaticCstrSignature); - if(NULL==cstrInternalBufferUtil) { + cstrBuffers = (*env)->GetStaticMethodID(env, clazzBuffers, + clazzNameBuffersStaticCstrName, clazzNameBuffersStaticCstrSignature); + if(NULL==cstrBuffers) { fprintf(stderr, "FatalError: Java_com_jogamp_opengl_impl_x11_glx_GLX:: can't create %s.%s %s\n", - clazzNameInternalBufferUtil, - clazzNameInternalBufferUtilStaticCstrName, clazzNameInternalBufferUtilStaticCstrSignature); - (*env)->FatalError(env, clazzNameInternalBufferUtilStaticCstrName); + clazzNameBuffers, + clazzNameBuffersStaticCstrName, clazzNameBuffersStaticCstrSignature); + (*env)->FatalError(env, clazzNameBuffersStaticCstrName); } } @@ -65,18 +65,21 @@ static void _initClazzAccess(JNIEnv *env) { * C function: XVisualInfo * glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_x11_glx_GLX_glXGetVisualFromFBConfigCopied0__JJ(JNIEnv *env, jclass _unused, jlong dpy, jlong config) { +Java_com_jogamp_opengl_impl_x11_glx_GLX_dispatch_1glXGetVisualFromFBConfig(JNIEnv *env, jclass _unused, jlong dpy, jlong config, jlong procAddress) { + typedef XVisualInfo* (APIENTRY*_local_PFNGLXGETVISUALFROMFBCONFIG)(Display * dpy, GLXFBConfig config); + _local_PFNGLXGETVISUALFROMFBCONFIG ptr_glXGetVisualFromFBConfig; XVisualInfo * _res; jobject jbyteSource; jobject jbyteCopy; - _res = glXGetVisualFromFBConfig((Display *) (intptr_t) dpy, (GLXFBConfig) (intptr_t) config); + ptr_glXGetVisualFromFBConfig = (_local_PFNGLXGETVISUALFROMFBCONFIG) (intptr_t) procAddress; + assert(ptr_glXGetVisualFromFBConfig != NULL); + _res = (* ptr_glXGetVisualFromFBConfig) ((Display *) (intptr_t) dpy, (GLXFBConfig) (intptr_t) config); if (_res == NULL) return NULL; _initClazzAccess(env); jbyteSource = (*env)->NewDirectByteBuffer(env, _res, sizeof(XVisualInfo)); - jbyteCopy = (*env)->CallStaticObjectMethod(env, - clazzInternalBufferUtil, cstrInternalBufferUtil, jbyteSource); + jbyteCopy = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource); (*env)->DeleteLocalRef(env, jbyteSource); XFree(_res); @@ -90,20 +93,24 @@ Java_com_jogamp_opengl_impl_x11_glx_GLX_glXGetVisualFromFBConfigCopied0__JJ(JNIE * C function: GLXFBConfig * glXChooseFBConfig(Display * dpy, int screen, const int * attribList, int * nitems); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_x11_glx_GLX_glXChooseFBConfigCopied1__JILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jobject nitems, jint nitems_byte_offset) { +Java_com_jogamp_opengl_impl_x11_glx_GLX_dispatch_1glXChooseFBConfig(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jobject nitems, jint nitems_byte_offset, jlong procAddress) { + typedef GLXFBConfig* (APIENTRY*_local_PFNGLXCHOOSEFBCONFIG)(Display * dpy, int screen, const int * attribList, int * nitems); + _local_PFNGLXCHOOSEFBCONFIG ptr_glXChooseFBConfig; int * _ptr2 = NULL; int * _ptr3 = NULL; GLXFBConfig * _res; int count; jobject jbyteSource; jobject jbyteCopy; + ptr_glXChooseFBConfig = (_local_PFNGLXCHOOSEFBCONFIG) (intptr_t) procAddress; + assert(ptr_glXChooseFBConfig != NULL); if (attribList != NULL) { _ptr2 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, attribList, NULL)) + attribList_byte_offset); } if (nitems != NULL) { _ptr3 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, nitems, NULL)) + nitems_byte_offset); } - _res = glXChooseFBConfig((Display *) (intptr_t) dpy, (int) screen, (int *) _ptr2, (int *) _ptr3); + _res = (*ptr_glXChooseFBConfig)((Display *) (intptr_t) dpy, (int) screen, (int *) _ptr2, (int *) _ptr3); count = _ptr3[0]; if (attribList != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, attribList, _ptr2, 0); @@ -116,8 +123,7 @@ Java_com_jogamp_opengl_impl_x11_glx_GLX_glXChooseFBConfigCopied1__JILjava_lang_O _initClazzAccess(env); jbyteSource = (*env)->NewDirectByteBuffer(env, _res, count * sizeof(GLXFBConfig)); - jbyteCopy = (*env)->CallStaticObjectMethod(env, - clazzInternalBufferUtil, cstrInternalBufferUtil, jbyteSource); + jbyteCopy = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource); (*env)->DeleteLocalRef(env, jbyteSource); XFree(_res); @@ -130,15 +136,19 @@ Java_com_jogamp_opengl_impl_x11_glx_GLX_glXChooseFBConfigCopied1__JILjava_lang_O * C function: XVisualInfo * glXChooseVisual(Display * dpy, int screen, int * attribList); */ JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_x11_glx_GLX_glXChooseVisualCopied1__JILjava_lang_Object_2I(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset) { +Java_com_jogamp_opengl_impl_x11_glx_GLX_dispatch_1glXChooseVisual(JNIEnv *env, jclass _unused, jlong dpy, jint screen, jobject attribList, jint attribList_byte_offset, jlong procAddress) { + typedef XVisualInfo* (APIENTRY*_local_PFNGLXCHOOSEVISUAL)(Display * dpy, int screen, int * attribList); + _local_PFNGLXCHOOSEVISUAL ptr_glXChooseVisual; int * _ptr2 = NULL; XVisualInfo * _res; jobject jbyteSource; jobject jbyteCopy; + ptr_glXChooseVisual = (_local_PFNGLXCHOOSEVISUAL) (intptr_t) procAddress; + assert(ptr_glXChooseVisual != NULL); if (attribList != NULL) { _ptr2 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, attribList, NULL)) + attribList_byte_offset); } - _res = glXChooseVisual((Display *) (intptr_t) dpy, (int) screen, (int *) _ptr2); + _res = (*ptr_glXChooseVisual)((Display *) (intptr_t) dpy, (int) screen, (int *) _ptr2); if (attribList != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, attribList, _ptr2, 0); } @@ -147,8 +157,7 @@ Java_com_jogamp_opengl_impl_x11_glx_GLX_glXChooseVisualCopied1__JILjava_lang_Obj _initClazzAccess(env); jbyteSource = (*env)->NewDirectByteBuffer(env, _res, sizeof(XVisualInfo)); - jbyteCopy = (*env)->CallStaticObjectMethod(env, - clazzInternalBufferUtil, cstrInternalBufferUtil, jbyteSource); + jbyteCopy = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffers, jbyteSource); (*env)->DeleteLocalRef(env, jbyteSource); XFree(_res); diff --git a/make/config/jogl/glx-CustomJavaCode.java b/make/config/jogl/glx-CustomJavaCode.java index fe81cd64a..0c3693b8b 100644 --- a/make/config/jogl/glx-CustomJavaCode.java +++ b/make/config/jogl/glx-CustomJavaCode.java @@ -1,46 +1,58 @@ /** Interface to C language function: <br> - Alias for: <br> <code> XVisualInfo * glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config); </code> */ - public static XVisualInfo glXGetVisualFromFBConfigCopied(long dpy, long config) + public static XVisualInfo glXGetVisualFromFBConfig(long dpy, long config) { + final long __addr_ = glxProcAddressTable._addressof_glXGetVisualFromFBConfig; + if (__addr_ == 0) { + throw new GLException("Method \"glXGetVisualFromFBConfig\" not available"); + } java.nio.ByteBuffer _res; - _res = glXGetVisualFromFBConfigCopied0(dpy, config); + _res = dispatch_glXGetVisualFromFBConfig(dpy, config, __addr_); if (_res == null) return null; return XVisualInfo.create(_res); } /** Entry point to C language function: - Alias for: <br> <code> XVisualInfo * glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config); </code> */ - private static native java.nio.ByteBuffer glXGetVisualFromFBConfigCopied0(long dpy, long config); + private static native java.nio.ByteBuffer dispatch_glXGetVisualFromFBConfig(long dpy, long config, long procAddr); /** Interface to C language function: <br> - Alias for: <br> <code> GLXFBConfig * glXChooseFBConfigSGIX, glXChooseFBConfig(Display * dpy, int screen, const int * attribList, int * nitems); </code> */ - public static com.jogamp.common.nio.PointerBuffer glXChooseFBConfigCopied(long dpy, int screen, int[] attribList, int attribList_offset, int[] nitems, int nitems_offset) + public static com.jogamp.common.nio.PointerBuffer glXChooseFBConfig(long dpy, int screen, int[] attribList, int attribList_offset, int[] nitems, int nitems_offset) { + final long __addr_ = glxProcAddressTable._addressof_glXChooseFBConfig; + if (__addr_ == 0) { + throw new GLException("Method \"glXGetVisualFromFBConfig\" not available"); + } if(attribList != null && attribList.length <= attribList_offset) throw new GLException("array offset argument \"attribList_offset\" (" + attribList_offset + ") equals or exceeds array length (" + attribList.length + ")"); if(nitems != null && nitems.length <= nitems_offset) throw new GLException("array offset argument \"nitems_offset\" (" + nitems_offset + ") equals or exceeds array length (" + nitems.length + ")"); java.nio.ByteBuffer _res; - _res = glXChooseFBConfigCopied1(dpy, screen, attribList, Buffers.SIZEOF_INT * attribList_offset, nitems, Buffers.SIZEOF_INT * nitems_offset); + _res = dispatch_glXChooseFBConfig(dpy, screen, attribList, Buffers.SIZEOF_INT * attribList_offset, nitems, Buffers.SIZEOF_INT * nitems_offset, __addr_); if (_res == null) return null; return PointerBuffer.wrap(_res); } /** Entry point to C language function: - Alias for: <br> <code> GLXFBConfig * glXChooseFBConfigSGIX, glXChooseFBConfig(Display * dpy, int screen, const int * attribList, int * nitems); </code> */ - private static native java.nio.ByteBuffer glXChooseFBConfigCopied1(long dpy, int screen, Object attribList, int attribList_byte_offset, Object nitems, int nitems_byte_offset); + private static native java.nio.ByteBuffer dispatch_glXChooseFBConfig(long dpy, int screen, Object attribList, int attribList_byte_offset, Object nitems, int nitems_byte_offset, long procAddr); /** Interface to C language function: <br> - Alias for: <br> <code> XVisualInfo * glXChooseVisual(Display * dpy, int screen, int * attribList); </code> */ - public static XVisualInfo glXChooseVisualCopied(long dpy, int screen, int[] attribList, int attribList_offset) + public static XVisualInfo glXChooseVisual(long dpy, int screen, int[] attribList, int attribList_offset) { + final long __addr_ = glxProcAddressTable._addressof_glXChooseVisual; + if (__addr_ == 0) { + throw new GLException("Method \"glXChooseVisual\" not available"); + } if(attribList != null && attribList.length <= attribList_offset) throw new GLException("array offset argument \"attribList_offset\" (" + attribList_offset + ") equals or exceeds array length (" + attribList.length + ")"); java.nio.ByteBuffer _res; - _res = glXChooseVisualCopied1(dpy, screen, attribList, Buffers.SIZEOF_INT * attribList_offset); + _res = dispatch_glXChooseVisual(dpy, screen, attribList, Buffers.SIZEOF_INT * attribList_offset, __addr_); if (_res == null) return null; return XVisualInfo.create(_res); } /** Entry point to C language function: - Alias for: <br> <code> XVisualInfo * glXChooseVisual(Display * dpy, int screen, int * attribList); </code> */ - private static native java.nio.ByteBuffer glXChooseVisualCopied1(long dpy, int screen, Object attribList, int attribList_byte_offset); + private static native java.nio.ByteBuffer dispatch_glXChooseVisual(long dpy, int screen, Object attribList, int attribList_byte_offset, long procAddr); diff --git a/make/config/jogl/glx-x11.cfg b/make/config/jogl/glx-x11.cfg index f451fa7f3..dee1d015f 100644 --- a/make/config/jogl/glx-x11.cfg +++ b/make/config/jogl/glx-x11.cfg @@ -5,7 +5,7 @@ NativeOutputDir gensrc/native/jogl/X11 Package com.jogamp.opengl.impl.x11.glx JavaClass GLX -Style allstatic +Style AllStatic Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg @@ -13,16 +13,17 @@ Include gl-desktop.cfg GLHeader GL/glx.h GLHeader GL/glxext.h +ForceProcAddressGen __ALL__ +LocalProcAddressCallingConvention __ALL__ APIENTRY + +AllowNonGLExtensions true EmitProcAddressTable true ProcAddressTableClassName GLXProcAddressTable GetProcAddressTableExpr glxProcAddressTable -# This must be present for bootstrapping -SkipProcAddressGen glXGetProcAddressARB Import com.jogamp.nativewindow.impl.x11.* Import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver - CustomJavaCode GLX private static GLXProcAddressTable glxProcAddressTable = new GLXProcAddressTable(new GLProcAddressResolver()); CustomJavaCode GLX public static GLXProcAddressTable getGLXProcAddressTable() { return glxProcAddressTable; } @@ -36,13 +37,16 @@ Opaque long GLXFBConfig Ignore glXCreateContextAttribsARB # -# We have Custom code for the following -Ignore glXGetVisualFromFBConfig +# We have manual code for the following (copying the return values) Ignore glXGetVisualFromFBConfigSGIX -Ignore glXChooseFBConfig -Ignore glXChooseVisual - -# Ignore everything not in the GLX core (up through GLX 1.4) aside from glXGetProcAddress +ManuallyImplement glXGetVisualFromFBConfig +ManuallyImplement glXChooseFBConfig +ManuallyImplement glXChooseVisual +ForceProcAddressGen glXGetVisualFromFBConfig +ForceProcAddressGen glXChooseFBConfig +ForceProcAddressGen glXChooseVisual + +# Ignore everything not in the GLX core (up through GLX 1.4) # FIXME: this needs to be kept in sync with the stub headers more than usual Ignore glXFreeContextEXT Ignore glXGetContextIDEXT @@ -86,3 +90,11 @@ Ignore GLXHyperpipeConfigSGIX Ignore GLXPipeRect Ignore GLXPipeRectLimits +CustomJavaCode GLX protected static long glXGetProcAddress(long glXGetProcAddressHandle, java.lang.String procname) +CustomJavaCode GLX { +CustomJavaCode GLX if (glXGetProcAddressHandle == 0) { +CustomJavaCode GLX throw new GLException("Passed null pointer for method \"glXGetProcAddress\""); +CustomJavaCode GLX } +CustomJavaCode GLX return dispatch_glXGetProcAddress1(procname, glXGetProcAddressHandle); +CustomJavaCode GLX } + diff --git a/make/config/jogl/glxext.cfg b/make/config/jogl/glxext.cfg index 1dfc8fccd..aeed3af4e 100755 --- a/make/config/jogl/glxext.cfg +++ b/make/config/jogl/glxext.cfg @@ -95,7 +95,6 @@ Ignore glXGetCurrentReadDrawable Ignore glXQueryContext Ignore glXSelectEvent Ignore glXGetSelectedEvent -Ignore glXGetProcAddress # Ignore a few extensions that bring in data types we don't want to # expose in the public API (and that are useless anyway without diff --git a/make/config/jogl/wgl-win32.cfg b/make/config/jogl/wgl-win32.cfg index 2a69290a4..97938a853 100644 --- a/make/config/jogl/wgl-win32.cfg +++ b/make/config/jogl/wgl-win32.cfg @@ -5,21 +5,30 @@ NativeOutputDir gensrc/native/jogl/Windows Package com.jogamp.opengl.impl.windows.wgl JavaClass WGL -Style allstatic +Style AllStatic Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg -AllowNonGLExtensions true - GLHeader wingdi.h GLHeader GL/wglext.h +ForceProcAddressGen __ALL__ +LocalProcAddressCallingConvention __ALL__ APIENTRY + +AllowNonGLExtensions true +EmitProcAddressTable true +ProcAddressTableClassName WGLProcAddressTable +GetProcAddressTableExpr wglProcAddressTable + +Import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver + +CustomJavaCode WGL private static WGLProcAddressTable wglProcAddressTable = new WGLProcAddressTable(new GLProcAddressResolver()); +CustomJavaCode WGL public static WGLProcAddressTable getWGLProcAddressTable() { return wglProcAddressTable; } + # Implement the first argument to wglGetProcAddress as String instead # of byte[] ArgumentIsString wglGetProcAddress 0 -ArgumentIsString LoadLibraryA 0 -ArgumentIsString GetProcAddress 1 CustomCCode #define WIN32_LEAN_AND_MEAN CustomCCode #include <windows.h> @@ -30,8 +39,6 @@ CustomCCode #include <stddef.h> Include ../intptr.cfg -IncludeAs CustomCCode wgl-CustomCCode.c - DropUniqVendorExtensions AMD # We need GL_APPLE_float_pixels for our pbuffer implementation # DropUniqVendorExtensions APPLE @@ -47,3 +54,11 @@ DropUniqVendorExtensions SGIX DropUniqVendorExtensions SUN DropUniqVendorExtensions WIN +CustomJavaCode WGL protected static long wglGetProcAddress(long wglGetProcAddressHandle, java.lang.String procname) +CustomJavaCode WGL { +CustomJavaCode WGL if (wglGetProcAddressHandle == 0) { +CustomJavaCode WGL throw new GLException("Passed null pointer for method \"wglGetProcAddress\""); +CustomJavaCode WGL } +CustomJavaCode WGL return dispatch_wglGetProcAddress1(procname, wglGetProcAddressHandle); +CustomJavaCode WGL } + diff --git a/make/config/jogl/wglext.cfg b/make/config/jogl/wglext.cfg index 35c43cb86..aca757b1c 100644 --- a/make/config/jogl/wglext.cfg +++ b/make/config/jogl/wglext.cfg @@ -36,6 +36,9 @@ GLHeader GL/wglext.h IgnoreExtension WGL_OML_sync_control IgnoreExtension WGL_NV_gpu_affinity +IgnoreExtension WGL_EXT_make_current_read +RenameExtensionIntoCore WGL_ARB_make_current_read + CustomJavaCode WGLExt public boolean isFunctionAvailable(String glFunctionName); CustomJavaCode WGLExt public boolean isExtensionAvailable(String glExtensionName); diff --git a/make/config/nativewindow/jawt-CustomJavaCode.java b/make/config/nativewindow/jawt-CustomJavaCode.java index 87d08241b..3223a74b1 100755 --- a/make/config/nativewindow/jawt-CustomJavaCode.java +++ b/make/config/nativewindow/jawt-CustomJavaCode.java @@ -5,7 +5,7 @@ public static JAWT getJAWT() { if (jawt == null) { synchronized (JAWT.class) { if (jawt == null) { - JAWTUtil.init(); + JAWTUtil.initSingleton(); // Workaround for 4845371. // Make sure the first reference to the JNI GetDirectBufferAddress is done // from a privileged context so the VM's internal class lookups will succeed. diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 6b5831215..41f726916 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -3,12 +3,12 @@ } /** Interface to C language function: <br> <code> XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); </code> */ - public static XVisualInfo[] XGetVisualInfoCopied(long arg0, long arg1, XVisualInfo arg2, int[] arg3, int arg3_offset) + public static XVisualInfo[] XGetVisualInfo(long arg0, long arg1, XVisualInfo arg2, int[] arg3, int arg3_offset) { if(arg3 != null && arg3.length <= arg3_offset) throw new RuntimeException("array offset argument \"arg3_offset\" (" + arg3_offset + ") equals or exceeds array length (" + arg3.length + ")"); java.nio.ByteBuffer _res; - _res = XGetVisualInfoCopied1(arg0, arg1, ((arg2 == null) ? null : arg2.getBuffer()), arg3, Buffers.SIZEOF_INT * arg3_offset); + _res = XGetVisualInfo1(arg0, arg1, ((arg2 == null) ? null : arg2.getBuffer()), arg3, Buffers.SIZEOF_INT * arg3_offset); if (_res == null) return null; Buffers.nativeOrder(_res); @@ -25,16 +25,13 @@ } /** Entry point to C language function: <code> XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); </code> */ - private static native java.nio.ByteBuffer XGetVisualInfoCopied1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset); + private static native java.nio.ByteBuffer XGetVisualInfo1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset); public static native long DefaultVisualID(long display, int screen); public static native long CreateDummyWindow(long display, int screen_index, long visualID); public static native void DestroyDummyWindow(long display, long window); - public static native long dlopen(String name); - public static native long dlsym(String name); - public static native int XCloseDisplay(long display); public static native void XUnlockDisplay(long display); public static native void XLockDisplay(long display); |