From 32790c376583beccd030eecd7c56cbe66d380172 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 20 Apr 2010 11:46:26 +0200 Subject: JOGL GL4 preperation (cont): - All available OpenGL versions (native/platform) are verified at GLProfile initialization and can be queried .. A mapping of major,compat -> major,minor,options is created. - Removal of temp context creation, when creating a context. This was necessary to query general availability of ARB_create_context. Due to the shared context of X11GLXDrawableFactory and WindowsWGLDrawableFactory, this is no more necessary. Due to the version mapping, the ARB_create_context paramters are known. - NativeWindow X11Lib: Added X11ErrorHandler, throwing a RuntimeException. Necessary to catch BadMatch .. etc X11 errors, eg for glXCreateContextAttribsARB Hence all X11 calls are covered now. - X11DummyGLXDrawable needs to use an own Window, otherwise GLn n>2 fails - Flattening the desktop GL* implementation, all use GL4bcImpl, which reduces the footprint dramatically. - GL*Impl.isGL*() (desktop) utilizes the GLContext.isGL*(), hence the results reflect the actual native context version. - GLContextImpl makeCurrent/create: Added workflow documentation, clarified code, defined abstract methods to have a protocol. - Removed moved files (from here to gluegen), see gluegen a01cb3d59715a41153380f1977ec75263b762dc6 - NativeLibLoader -> JNILibLoader - Fixed Exception Handling (as in gluegen bce53b52c8638729750c4286dbc04cb14329fd34), ie removed empty catch Throwable .. - GLContext.setSwapInterval(): Nop in offscreen case, otherwise X11IOError (NVIDIA Bug) Test: Tests - Junit - demos.gears.Gears - demos.jrefract.JRefract Platforms - Linux 64/32 ATI/NVidia - MacOsX - Windows (virtualbox 3.1.6, offscreen failed) TODO/BUGS: - FIXME ATI GLn n>2 with AWT, can't make context current, works well on NVIDIA though - FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! - Add GL 3.3 to GL3/gl3ext.h - Add GL 4.0 to GL3/gl3ext.h and fix the GL3/GL4 seperation - Rename jogl.gl2.jar -> jogl.gldesktop.jar (as done with it's native lib already) --- make/config/jogl/cg-common-CustomJavaCode.java | 2 +- make/config/jogl/gl-gl2.cfg | 48 +- make/config/jogl/gl-gl2es12.cfg | 90 ---- make/config/jogl/gl-gl3.cfg | 43 +- make/config/jogl/gl-gl3bc.cfg | 64 +-- make/config/jogl/gl-gl4.cfg | 37 ++ make/config/jogl/gl-gl4bc.cfg | 110 +++++ make/config/jogl/gl-impl-CustomCCode-gl2.c | 24 - make/config/jogl/gl-impl-CustomCCode-gl2es12.c | 24 - make/config/jogl/gl-impl-CustomCCode-gl3.c | 24 - make/config/jogl/gl-impl-CustomCCode-gl3bc.c | 24 - make/config/jogl/gl-impl-CustomCCode-gl4bc.c | 24 + .../config/jogl/gl-impl-CustomJavaCode-common.java | 74 ++- .../jogl/gl-impl-CustomJavaCode-desktop.java | 250 +++++++--- make/config/jogl/gl-impl-CustomJavaCode-gl2.java | 514 --------------------- .../jogl/gl-impl-CustomJavaCode-gl2es12.java | 455 ------------------ make/config/jogl/gl-impl-CustomJavaCode-gl3.java | 468 ------------------- make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java | 514 --------------------- make/config/jogl/gl-impl-CustomJavaCode-gl4.java | 339 ++++++++++++++ make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 385 +++++++++++++++ make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 41 -- make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 41 -- make/config/jogl/gl3-common.cfg | 3 + make/config/jogl/gl3-desktop-tracker.cfg | 38 -- make/config/jogl/gl4-common.cfg | 5 + make/config/jogl/gl4-desktop-tracker.cfg | 38 ++ make/config/jogl/glu-CustomJavaCode-base.java | 4 +- make/config/jogl/glu-CustomJavaCode-gl2es1.java | 2 +- make/config/jogl/glu-common.cfg | 2 +- make/config/jogl/obsolete/gl-gl2es12.cfg | 90 ++++ .../config/jogl/obsolete/gl-impl-CustomCCode-gl2.c | 24 + .../jogl/obsolete/gl-impl-CustomCCode-gl2es12.c | 24 + .../config/jogl/obsolete/gl-impl-CustomCCode-gl3.c | 24 + .../jogl/obsolete/gl-impl-CustomJavaCode-gl2.java | 385 +++++++++++++++ .../obsolete/gl-impl-CustomJavaCode-gl2es12.java | 353 ++++++++++++++ make/config/nativewindow/x11-CustomJavaCode.java | 3 +- 36 files changed, 2099 insertions(+), 2491 deletions(-) delete mode 100644 make/config/jogl/gl-gl2es12.cfg create mode 100644 make/config/jogl/gl-gl4.cfg create mode 100644 make/config/jogl/gl-gl4bc.cfg delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gl2.c delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gl2es12.c delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gl3.c delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gl3bc.c create mode 100644 make/config/jogl/gl-impl-CustomCCode-gl4bc.c delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl2.java delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl3.java delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java create mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl4.java create mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java delete mode 100644 make/config/jogl/gl3-desktop-tracker.cfg create mode 100644 make/config/jogl/gl4-common.cfg create mode 100644 make/config/jogl/gl4-desktop-tracker.cfg create mode 100644 make/config/jogl/obsolete/gl-gl2es12.cfg create mode 100644 make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c create mode 100644 make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c create mode 100644 make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c create mode 100644 make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java create mode 100644 make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java (limited to 'make/config') diff --git a/make/config/jogl/cg-common-CustomJavaCode.java b/make/config/jogl/cg-common-CustomJavaCode.java index 974e24bf4..d1e4f8bf5 100755 --- a/make/config/jogl/cg-common-CustomJavaCode.java +++ b/make/config/jogl/cg-common-CustomJavaCode.java @@ -1,5 +1,5 @@ static { - com.jogamp.opengl.impl.NativeLibLoader.loadCgImpl(); + com.jogamp.opengl.impl.GLJNILibLoader.loadCgImpl(); } /** A convenience method which reads all available data from the InputStream and then calls cgCreateProgram. */ diff --git a/make/config/jogl/gl-gl2.cfg b/make/config/jogl/gl-gl2.cfg index 37452d159..48dd8eda6 100644 --- a/make/config/jogl/gl-gl2.cfg +++ b/make/config/jogl/gl-gl2.cfg @@ -12,72 +12,32 @@ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java Package javax.media.opengl -Style InterfaceAndImpl +Style InterfaceOnly JavaClass GL2 Extends GL2 GLBase Extends GL2 GL Extends GL2 GL2ES1 Extends GL2 GL2ES2 Extends GL2 GL2GL3 -ImplPackage com.jogamp.opengl.impl.gl2 -ImplJavaClass GL2Impl -Implements GL2Impl GLBase -Implements GL2Impl GL -Implements GL2Impl GL2ES1 -Implements GL2Impl GL2ES2 -Implements GL2Impl GL2GL3 Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg -EmitProcAddressTable true -ProcAddressTableClassName GL2ProcAddressTable -GetProcAddressTableExpr ((GL2ProcAddressTable)_context.getGLProcAddressTable()) - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true # Ignore extensions that are already picked up via the GL2ES1 interface IgnoreExtension GL_EXT_point_parameters -# Add PixelStorei StateTracker -# -CustomJavaCode GL2Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. - -JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); - -JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } - CustomJavaCode GL2 public boolean glIsPBOPackEnabled(); CustomJavaCode GL2 public boolean glIsPBOUnpackEnabled(); IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl2.java -CustomJavaCode GL2Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL2Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL2Impl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL2Impl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL2Impl public void glClearDepthf(float depth) { -CustomJavaCode GL2Impl glClearDepth((double)depth); } - -CustomJavaCode GL2Impl public void glDepthRangef(float zNear, float zFar) { -CustomJavaCode GL2Impl glDepthRange((double)zNear, (double)zFar); } - Include gl-headers.cfg Include ../intptr.cfg -IncludeAs CustomJavaCode GL2Impl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GL2Impl gl-impl-CustomJavaCode-gl2.java -IncludeAs CustomJavaCode GL2Impl gl-impl-CustomJavaCode-desktop.java -IncludeAs CustomJavaCode GL2Impl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gl2.c +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff -Import javax.media.opengl.GLES1 -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 java.io.PrintStream diff --git a/make/config/jogl/gl-gl2es12.cfg b/make/config/jogl/gl-gl2es12.cfg deleted file mode 100644 index 3942b1419..000000000 --- a/make/config/jogl/gl-gl2es12.cfg +++ /dev/null @@ -1,90 +0,0 @@ -# This .cfg file is used to generate the GL interface and implementing class. -JavaOutputDir gensrc/classes -NativeOutputDir gensrc/native/jogl/gl2es12 - -ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL.java -ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java -ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java -ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/GLBase.java -ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java -ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java -ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java - -Style ImplOnly -ImplPackage com.jogamp.opengl.impl.gl2es12 -ImplJavaClass GL2ES12Impl -Implements GL2ES12Impl GLBase -Implements GL2ES12Impl GL -Implements GL2ES12Impl GL2ES1 -Implements GL2ES12Impl GL2ES2 - -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 -ForceProcAddressGen __ALL__ - -# Also force the calling conventions of the locally generated function -# pointer typedefs for these routines to APIENTRY -LocalProcAddressCallingConvention __ALL__ APIENTRY - -EmitProcAddressTable true -ProcAddressTableClassName GL2ES12ProcAddressTable -GetProcAddressTableExpr ((GL2ES12ProcAddressTable)_context.getGLProcAddressTable()) - -# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums -TagNativeBinding true - -# There seem to be some errors in the glue code generation where we are not ignoring -# enough routines from desktop GL in GL2ES12Impl. For now manually ignore those which -# we know shouldn't be in there -Ignore glGetTexImage -Ignore glPixelStoref - -# Add PixelStorei StateTracker -# -# Add input validation to glPixelStorei to make sure that, even if we -# are running on top of desktop OpenGL, parameters not exposed in -# OpenGL ES can not be changed -CustomJavaCode GL2ES12Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. - -JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { -JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname)); -JavaPrologue glPixelStorei } -JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); - -JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } - -CustomJavaCode GL2ES12Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL2ES12Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL2ES12Impl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL2ES12Impl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL2ES12Impl public void glClearDepthf(float depth) { -CustomJavaCode GL2ES12Impl glClearDepth((double)depth); } - -CustomJavaCode GL2ES12Impl public void glDepthRangef(float zNear, float zFar) { -CustomJavaCode GL2ES12Impl glDepthRange((double)zNear, (double)zFar); } - -Include gl-headers.cfg -Include ../intptr.cfg - -IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2es12.java -IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-embedded.java -IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gl2es12.c - -Import javax.media.opengl.GLES1 -Import javax.media.opengl.GLES2 -Import com.jogamp.opengl.impl.InternalBufferUtil -Import java.io.PrintStream diff --git a/make/config/jogl/gl-gl3.cfg b/make/config/jogl/gl-gl3.cfg index 0bfe2cc38..d5e0003d4 100644 --- a/make/config/jogl/gl-gl3.cfg +++ b/make/config/jogl/gl-gl3.cfg @@ -8,7 +8,7 @@ ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/G ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java Package javax.media.opengl -Style InterfaceAndImpl +Style InterfaceOnly JavaClass GL3 Extends GL3 GLBase Extends GL3 GL @@ -27,48 +27,15 @@ Include gl3-desktop.cfg IncludeAs CustomJavaCode GL3 gl-if-CustomJavaCode-gl3.java -EmitProcAddressTable true -ProcAddressTableClassName GL3ProcAddressTable -GetProcAddressTableExpr ((GL3ProcAddressTable)_context.getGLProcAddressTable()) - -# 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 -ForceProcAddressGen __ALL__ - -# Also force the calling conventions of the locally generated function -# pointer typedefs for these routines to APIENTRY -LocalProcAddressCallingConvention __ALL__ APIENTRY +EmitProcAddressTable false # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true -# Add PixelStorei StateTracker -# -CustomJavaCode GL3Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. - -JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); - -JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } - -CustomJavaCode GL3Impl public void glClearDepthf(float depth) { -CustomJavaCode GL3Impl glClearDepth((double)depth); } - -CustomJavaCode GL3Impl public void glDepthRangef(float zNear, float zFar) { -CustomJavaCode GL3Impl glDepthRange((double)zNear, (double)zFar); } - Include gl3-headers.cfg Include ../intptr.cfg -IncludeAs CustomJavaCode GL3Impl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GL3Impl gl-impl-CustomJavaCode-gl3.java -IncludeAs CustomJavaCode GL3Impl gl-impl-CustomJavaCode-desktop.java -IncludeAs CustomJavaCode GL3Impl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gl3.c +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff -Import javax.media.opengl.GLES2 -Import javax.media.opengl.GL3 -Import javax.media.opengl.GLArrayData -Import javax.media.opengl.GLUniformData -Import com.jogamp.opengl.impl.InternalBufferUtil -Import java.io.PrintStream diff --git a/make/config/jogl/gl-gl3bc.cfg b/make/config/jogl/gl-gl3bc.cfg index 7bba2f635..7c53ea8d6 100644 --- a/make/config/jogl/gl-gl3bc.cfg +++ b/make/config/jogl/gl-gl3bc.cfg @@ -14,7 +14,7 @@ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java Package javax.media.opengl -Style InterfaceAndImpl +Style InterfaceOnly JavaClass GL3bc Extends GL3bc GLBase Extends GL3bc GL @@ -23,15 +23,6 @@ Extends GL3bc GL2ES2 Extends GL3bc GL2GL3 Extends GL3bc GL2 Extends GL3bc GL3 -ImplPackage com.jogamp.opengl.impl.gl3 -ImplJavaClass GL3bcImpl -Implements GL3bcImpl GLBase -Implements GL3bcImpl GL -Implements GL3bcImpl GL2ES1 -Implements GL3bcImpl GL2ES2 -Implements GL3bcImpl GL2GL3 -Implements GL3bcImpl GL2 -Implements GL3bcImpl GL3 Include gl-common.cfg Include gl-common-extensions.cfg @@ -39,64 +30,17 @@ Include gl-desktop.cfg Include gl3-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 - -# 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 -ForceProcAddressGen __ALL__ - -# Also force the calling conventions of the locally generated function -# pointer typedefs for these routines to APIENTRY -LocalProcAddressCallingConvention __ALL__ APIENTRY - -EmitProcAddressTable true -ProcAddressTableClassName GL3bcProcAddressTable -GetProcAddressTableExpr ((GL3bcProcAddressTable)_context.getGLProcAddressTable()) - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true # Ignore extensions that are already picked up via the GL2ES1 interface IgnoreExtension GL_EXT_point_parameters -# Add PixelStorei StateTracker -CustomJavaCode GL3bcImpl private static final int params_offset = 0; // just a helper for JavaPrologue .. - -JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); - -JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } - -CustomJavaCode GL3bcImpl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL3bcImpl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL3bcImpl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL3bcImpl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } - -CustomJavaCode GL3bcImpl public void glClearDepthf(float depth) { -CustomJavaCode GL3bcImpl glClearDepth((double)depth); } - -CustomJavaCode GL3bcImpl public void glDepthRangef(float zNear, float zFar) { -CustomJavaCode GL3bcImpl glDepthRange((double)zNear, (double)zFar); } - Include gl-headers.cfg Include gl3ext-headers.cfg Include ../intptr.cfg -IncludeAs CustomJavaCode GL3bcImpl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GL3bcImpl gl-impl-CustomJavaCode-gl3bc.java -IncludeAs CustomJavaCode GL3bcImpl gl-impl-CustomJavaCode-desktop.java -IncludeAs CustomJavaCode GL3bcImpl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gl3bc.c +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff -Import javax.media.opengl.GLES1 -Import javax.media.opengl.GLES2 -Import javax.media.opengl.GL2GL3 -Import javax.media.opengl.GL2 -Import javax.media.opengl.GL3 -Import javax.media.opengl.GL3bc -Import com.jogamp.opengl.impl.InternalBufferUtil -Import java.io.PrintStream diff --git a/make/config/jogl/gl-gl4.cfg b/make/config/jogl/gl-gl4.cfg new file mode 100644 index 000000000..1d4392899 --- /dev/null +++ b/make/config/jogl/gl-gl4.cfg @@ -0,0 +1,37 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/gl4 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL4 +Extends GL4 GLBase +Extends GL4 GL +Extends GL4 GL2ES2 +Extends GL4 GL2GL3 +Extends GL4 GL3 +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl3-common.cfg +Include gl4-common.cfg +Include gl3-desktop.cfg + +IncludeAs CustomJavaCode GL4 gl-if-CustomJavaCode-gl3.java + +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff + + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Include gl3-headers.cfg +Include ../intptr.cfg + diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg new file mode 100644 index 000000000..3a3e02041 --- /dev/null +++ b/make/config/jogl/gl-gl4bc.cfg @@ -0,0 +1,110 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/gl4 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3bc.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java + +Package javax.media.opengl +Style InterfaceAndImpl +JavaClass GL4bc +Extends GL4bc GLBase +Extends GL4bc GL +Extends GL4bc GL2ES1 +Extends GL4bc GL2ES2 +Extends GL4bc GL2GL3 +Extends GL4bc GL2 +Extends GL4bc GL3 +Extends GL4bc GL3bc +Extends GL4bc GL4 +ImplPackage com.jogamp.opengl.impl.gl4 +ImplJavaClass GL4bcImpl +Implements GL4bcImpl GLBase +Implements GL4bcImpl GL +Implements GL4bcImpl GL2ES1 +Implements GL4bcImpl GL2ES2 +Implements GL4bcImpl GL2GL3 +Implements GL4bcImpl GL2 +Implements GL4bcImpl GL3 +Implements GL4bcImpl GL3bc +Implements GL4bcImpl GL4 + +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl-desktop.cfg +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 + +# 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 +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +EmitProcAddressTable true +ProcAddressTableClassName GL4bcProcAddressTable +GetProcAddressTableExpr ((GL4bcProcAddressTable)_context.getGLProcAddressTable()) + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# Ignore extensions that are already picked up via the GL2ES1 interface +IgnoreExtension GL_EXT_point_parameters + +# Add PixelStorei StateTracker +CustomJavaCode GL4bcImpl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + +CustomJavaCode GL4bcImpl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { +CustomJavaCode GL4bcImpl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } + +CustomJavaCode GL4bcImpl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { +CustomJavaCode GL4bcImpl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } + +CustomJavaCode GL4bcImpl public void glClearDepthf(float depth) { +CustomJavaCode GL4bcImpl glClearDepth((double)depth); } + +CustomJavaCode GL4bcImpl public void glDepthRangef(float zNear, float zFar) { +CustomJavaCode GL4bcImpl glDepthRange((double)zNear, (double)zFar); } + +Include gl-headers.cfg +Include gl3ext-headers.cfg +Include ../intptr.cfg + +IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-common.java +IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-gl4bc.java +IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-desktop.java +IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-gl2_es2.java +IncludeAs CustomCCode gl-impl-CustomCCode-gl4bc.c + +Import javax.media.opengl.GLES1 +Import javax.media.opengl.GLES2 +Import javax.media.opengl.GL2GL3 +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 java.io.PrintStream diff --git a/make/config/jogl/gl-impl-CustomCCode-gl2.c b/make/config/jogl/gl-impl-CustomCCode-gl2.c deleted file mode 100644 index 91fd0078b..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gl2.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl2.GL2Impl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_com_jogamp_opengl_impl_gl2_GL2Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { - PFNGLMAPBUFFERPROC ptr_glMapBuffer; - void * _res; - ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; - assert(ptr_glMapBuffer != NULL); - _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); - return (jlong) (intptr_t) _res; -} - -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl2.GL2Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); - */ -JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_gl2_GL2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gl2es12.c b/make/config/jogl/gl-impl-CustomCCode-gl2es12.c deleted file mode 100644 index 07b821802..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gl2es12.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { - PFNGLMAPBUFFERPROC ptr_glMapBuffer; - void * _res; - ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; - assert(ptr_glMapBuffer != NULL); - _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); - return (jlong) (intptr_t) _res; -} - -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); - */ -JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gl3.c b/make/config/jogl/gl-impl-CustomCCode-gl3.c deleted file mode 100644 index f540a7d4a..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gl3.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl3.GL3Impl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_com_jogamp_opengl_impl_gl3_GL3Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { - PFNGLMAPBUFFERPROC ptr_glMapBuffer; - void * _res; - ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; - assert(ptr_glMapBuffer != NULL); - _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); - return (jlong) (intptr_t) _res; -} - -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl3.GL3Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); - */ -JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_gl3_GL3Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gl3bc.c b/make/config/jogl/gl-impl-CustomCCode-gl3bc.c deleted file mode 100644 index 21de8c925..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gl3bc.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl3.GL3bcImpl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_com_jogamp_opengl_impl_gl3_GL3bcImpl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { - PFNGLMAPBUFFERPROC ptr_glMapBuffer; - void * _res; - ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; - assert(ptr_glMapBuffer != NULL); - _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); - return (jlong) (intptr_t) _res; -} - -/* Java->C glue code: - * Java package: com.jogamp.opengl.impl.gl3.GL3bcImpl - * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); - */ -JNIEXPORT jobject JNICALL -Java_com_jogamp_opengl_impl_gl3_GL3bcImpl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c new file mode 100644 index 000000000..bcda20fa4 --- /dev/null +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -0,0 +1,24 @@ +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl4.GL4bcImpl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { + PFNGLMAPBUFFERPROC ptr_glMapBuffer; + void * _res; + ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; + assert(ptr_glMapBuffer != NULL); + _res = (* ptr_glMapBuffer) ((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); + */ +JNIEXPORT jobject JNICALL +Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { + return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); +} diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 564606799..4872490b0 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -1,16 +1,58 @@ - public GLProfile getGLProfile() { - return this.glProfile; - } - private GLProfile glProfile; - - public int glGetBoundBuffer(int target) { - return bufferStateTracker.getBoundBufferObject(target, this); - } - - public boolean glIsVBOArrayEnabled() { - return checkArrayVBOEnabled(false); - } - - public boolean glIsVBOElementEnabled() { - return checkElementVBOEnabled(false); - } + public GLProfile getGLProfile() { + return this.glProfile; + } + private GLProfile glProfile; + + public int glGetBoundBuffer(int target) { + return bufferStateTracker.getBoundBufferObject(target, this); + } + + public boolean glIsVBOArrayEnabled() { + return checkArrayVBOEnabled(false); + } + + public boolean glIsVBOElementEnabled() { + return checkElementVBOEnabled(false); + } + + public final boolean isGL() { + return true; + } + + public final GL getGL() throws GLException { + return this; + } + + public boolean isFunctionAvailable(String glFunctionName) { + return _context.isFunctionAvailable(glFunctionName); + } + + public boolean isExtensionAvailable(String glExtensionName) { + return _context.isExtensionAvailable(glExtensionName); + } + + public Object getExtension(String extensionName) { + // At this point we don't expose any extensions using this mechanism + return null; + } + + /** Returns the context this GL object is associated with for better + error checking by DebugGL. */ + public GLContext getContext() { + return _context; + } + + private GLContextImpl _context; + + public void setSwapInterval(int interval) { + _context.setSwapInterval(interval); + } + + public int getSwapInterval() { + return _context.getSwapInterval(); + } + + public Object getPlatformGLExtensions() { + return _context.getPlatformGLExtensions(); + } + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java index 04ba39c3d..93a275269 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java @@ -1,79 +1,191 @@ -private int[] imageSizeTemp = new int[1]; - -/** Helper for more precise computation of number of bytes that will - be touched by a pixel pack or unpack operation. */ -private int imageSizeInBytes(int bytesPerElement, - int width, int height, int depth, boolean pack) { - int rowLength = 0; - int skipRows = 0; - int skipPixels = 0; - int alignment = 1; - int imageHeight = 0; - int skipImages = 0; - - if (pack) { - glGetIntegerv(GL_PACK_ROW_LENGTH, imageSizeTemp, 0); - rowLength = imageSizeTemp[0]; - glGetIntegerv(GL_PACK_SKIP_ROWS, imageSizeTemp, 0); - skipRows = imageSizeTemp[0]; - glGetIntegerv(GL_PACK_SKIP_PIXELS, imageSizeTemp, 0); - skipPixels = imageSizeTemp[0]; - glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0); - alignment = imageSizeTemp[0]; - if (depth > 1) { - glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0); - imageHeight = imageSizeTemp[0]; - glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0); - skipImages = imageSizeTemp[0]; + private int[] imageSizeTemp = new int[1]; + + /** Helper for more precise computation of number of bytes that will + be touched by a pixel pack or unpack operation. */ + private int imageSizeInBytes(int bytesPerElement, + int width, int height, int depth, boolean pack) { + int rowLength = 0; + int skipRows = 0; + int skipPixels = 0; + int alignment = 1; + int imageHeight = 0; + int skipImages = 0; + + if (pack) { + glGetIntegerv(GL_PACK_ROW_LENGTH, imageSizeTemp, 0); + rowLength = imageSizeTemp[0]; + glGetIntegerv(GL_PACK_SKIP_ROWS, imageSizeTemp, 0); + skipRows = imageSizeTemp[0]; + glGetIntegerv(GL_PACK_SKIP_PIXELS, imageSizeTemp, 0); + skipPixels = imageSizeTemp[0]; + glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0); + alignment = imageSizeTemp[0]; + if (depth > 1) { + glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0); + imageHeight = imageSizeTemp[0]; + glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0); + skipImages = imageSizeTemp[0]; + } + } else { + glGetIntegerv(GL_UNPACK_ROW_LENGTH, imageSizeTemp, 0); + rowLength = imageSizeTemp[0]; + glGetIntegerv(GL_UNPACK_SKIP_ROWS, imageSizeTemp, 0); + skipRows = imageSizeTemp[0]; + glGetIntegerv(GL_UNPACK_SKIP_PIXELS, imageSizeTemp, 0); + skipPixels = imageSizeTemp[0]; + glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0); + alignment = imageSizeTemp[0]; + if (depth > 1) { + glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0); + imageHeight = imageSizeTemp[0]; + glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0); + skipImages = imageSizeTemp[0]; + } } - } else { - glGetIntegerv(GL_UNPACK_ROW_LENGTH, imageSizeTemp, 0); - rowLength = imageSizeTemp[0]; - glGetIntegerv(GL_UNPACK_SKIP_ROWS, imageSizeTemp, 0); - skipRows = imageSizeTemp[0]; - glGetIntegerv(GL_UNPACK_SKIP_PIXELS, imageSizeTemp, 0); - skipPixels = imageSizeTemp[0]; - glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0); - alignment = imageSizeTemp[0]; - if (depth > 1) { - glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0); - imageHeight = imageSizeTemp[0]; - glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0); - skipImages = imageSizeTemp[0]; + // Try to deal somewhat correctly with potentially invalid values + width = Math.max(0, width ); + height = Math.max(1, height); // min 1D + depth = Math.max(1, depth ); // min 1 * imageSize + skipRows = Math.max(0, skipRows); + skipPixels = Math.max(0, skipPixels); + alignment = Math.max(1, alignment); + skipImages = Math.max(0, skipImages); + + imageHeight = ( imageHeight > 0 ) ? imageHeight : height; + rowLength = ( rowLength > 0 ) ? rowLength : width; + + int rowLengthInBytes = rowLength * bytesPerElement; + + if (alignment > 1) { + int padding = rowLengthInBytes % alignment; + if (padding > 0) { + rowLengthInBytes += alignment - padding; + } } + + /** + * skipPixels and skipRows is a static one time offset. + * + * skipImages and depth are in multiples of image size. + * + * rowlenght is the actual repeating offset + * to go from line n to line n+1 at the same x-axis position. + */ + return + ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // whole images + ( skipRows + height - 1 ) * rowLengthInBytes + // lines with padding + ( skipPixels + width ) * bytesPerElement; // last line + } + + public final boolean isGL4bc() { + return _context.isGL4bc(); + } + + public final boolean isGL4() { + return _context.isGL4(); + } + + public final boolean isGL3bc() { + return _context.isGL3bc(); + } + + public final boolean isGL3() { + return _context.isGL3(); } - // Try to deal somewhat correctly with potentially invalid values - width = Math.max(0, width ); - height = Math.max(1, height); // min 1D - depth = Math.max(1, depth ); // min 1 * imageSize - skipRows = Math.max(0, skipRows); - skipPixels = Math.max(0, skipPixels); - alignment = Math.max(1, alignment); - skipImages = Math.max(0, skipImages); - imageHeight = ( imageHeight > 0 ) ? imageHeight : height; - rowLength = ( rowLength > 0 ) ? rowLength : width; + public final boolean isGL2() { + return _context.isGL2(); + } + + public final boolean isGL2ES1() { + return _context.isGL2ES1(); + } - int rowLengthInBytes = rowLength * bytesPerElement; + public final boolean isGL2ES2() { + return _context.isGL2ES2(); + } - if (alignment > 1) { - int padding = rowLengthInBytes % alignment; - if (padding > 0) { - rowLengthInBytes += alignment - padding; + public final boolean isGL2GL3() { + return _context.isGL2GL3(); + } + + public final boolean hasGLSL() { + return _context.hasGLSL(); + } + + public final GL4bc getGL4bc() throws GLException { + if(!isGL4bc()) { + throw new GLException("Not a GL4bc implementation"); + } + return this; + } + + public final GL4 getGL4() throws GLException { + if(!isGL4bc()) { + throw new GLException("Not a GL4 implementation"); } + return this; } - /** - * skipPixels and skipRows is a static one time offset. - * - * skipImages and depth are in multiples of image size. - * - * rowlenght is the actual repeating offset - * to go from line n to line n+1 at the same x-axis position. - */ - return - ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // whole images - ( skipRows + height - 1 ) * rowLengthInBytes + // lines with padding - ( skipPixels + width ) * bytesPerElement; // last line -} + public final GL3bc getGL3bc() throws GLException { + if(!isGL3bc()) { + throw new GLException("Not a GL3bc implementation"); + } + return this; + } + + public final GL3 getGL3() throws GLException { + if(!isGL3()) { + throw new GLException("Not a GL3 implementation"); + } + return this; + } + + public final GL2 getGL2() throws GLException { + if(!isGL2()) { + throw new GLException("Not a GL2 implementation"); + } + return this; + } + + public final GL2ES1 getGL2ES1() throws GLException { + if(!isGL2ES1()) { + throw new GLException("Not a GL2ES1 implementation"); + } + return this; + } + + public final GL2ES2 getGL2ES2() throws GLException { + if(!isGL2ES2()) { + throw new GLException("Not a GL2ES2 implementation"); + } + return this; + } + + public final GL2GL3 getGL2GL3() throws GLException { + if(!isGL2GL3()) { + throw new GLException("Not a GL2GL3 implementation"); + } + return this; + } + + public final boolean isGLES1() { + return false; + } + + public final boolean isGLES2() { + return false; + } + + public final boolean isGLES() { + return false; + } + + public final GLES1 getGLES1() throws GLException { + throw new GLException("Not a GLES1 implementation"); + } + + public final GLES2 getGLES2() throws GLException { + throw new GLException("Not a GLES2 implementation"); + } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2.java deleted file mode 100644 index 0658b8a01..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2.java +++ /dev/null @@ -1,514 +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 GL2Impl(GLProfile glp, GLContextImpl context) { - this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - this.glProfile = glp; -} - -public final boolean isGL() { - return true; -} - -public final boolean isGL4bc() { - return false; -} - -public final boolean isGL4() { - return false; -} - -public final boolean isGL3bc() { - return false; -} - -public final boolean isGL3() { - return false; -} - -public final boolean isGL2() { - return true; -} - -public final boolean isGLES1() { - return false; -} - -public final boolean isGLES2() { - return false; -} - -public final boolean isGLES() { - return false; -} - -public final boolean isGL2ES1() { - return true; -} - -public final boolean isGL2ES2() { - return true; -} - -public final boolean isGL2GL3() { - return true; -} - -public final boolean hasGLSL() { - return true; -} - -public final GL getGL() throws GLException { - return this; -} - -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -public final GL3bc getGL3bc() throws GLException { - throw new GLException("Not a GL3bc implementation"); -} - -public final GL3 getGL3() throws GLException { - throw new GLException("Not a GL3 implementation"); -} - -public final GL2 getGL2() throws GLException { - return this; -} - -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); -} - -public final GL2ES1 getGL2ES1() throws GLException { - return this; -} - -public final GL2ES2 getGL2ES2() throws GLException { - return this; -} - -public final GL2GL3 getGL2GL3() throws GLException { - return this; -} - -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -/** - * 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); -} - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - -// -// 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_COLOR_INDEX: - 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: - case GL_ABGR_EXT: - elements = 4; - break; - /* FIXME ?? - case GL_HILO_NV: - elements = 2; - break; */ - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX) { - return (d * (h * ((w+7)/8))); - } else { - return 0; - } - 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/**/ arbVBOCache = new HashMap(); - -/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ -public java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GL2ProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ -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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 - } - - public void glVertexPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glColorPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - - } - public void glNormalPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.getComponentNumber()!=3) { - throw new GLException("Only 3 components per normal allowed"); - } - if(array.isVBO()) { - glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glTexCoordPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java deleted file mode 100644 index 54c7bd92b..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl2es12.java +++ /dev/null @@ -1,455 +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 GL2ES12Impl(GLProfile glp, GLContextImpl context) { - this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - this.isGL2ES2 = glp.isGL2ES2(); - this.glProfile = glp; -} - -private boolean isGL2ES2; - -public final boolean isGL() { - return true; -} - -public final boolean isGL4bc() { - return false; -} - -public final boolean isGL4() { - return false; -} - -public final boolean isGL3bc() { - return false; -} - -public final boolean isGL3() { - return false; -} - -public final boolean isGL2() { - return false; -} - -public final boolean isGLES1() { - return false; -} - -public final boolean isGLES2() { - return false; -} - -public final boolean isGLES() { - return false; -} - -public final boolean isGL2ES1() { - return !isGL2ES2; -} - -public final boolean isGL2ES2() { - return isGL2ES2; -} - -public final boolean isGL2GL3() { - return false; -} - -public final boolean hasGLSL() { - return isGL2ES2; -} - -public final GL getGL() throws GLException { - return this; -} - -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -public final GL3bc getGL3bc() throws GLException { - throw new GLException("Not a GL3bc implementation"); -} - -public final GL3 getGL3() throws GLException { - throw new GLException("Not a GL3 implementation"); -} - -public final GL2 getGL2() throws GLException { - throw new GLException("Not a GL2 implementation"); -} - -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); -} - -public final GL2ES1 getGL2ES1() throws GLException { - if (isGL2ES1()) { - return this; - } - throw new GLException("Not a GL2ES1 implementation"); -} - -public final GL2ES2 getGL2ES2() throws GLException { - if (isGL2ES2()) { - return this; - } - throw new GLException("Not a GL2ES2 implementation"); -} - -public final GL2GL3 getGL2GL3() throws GLException { - throw new GLException("Not a GL2GL3 implementation"); -} - -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - -// -// 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_ALPHA: - case GL_LUMINANCE: - case GL_DEPTH_COMPONENT: - elements = 1; - break; - case GL_LUMINANCE_ALPHA: - elements = 2; - break; - case GL_RGB: - elements = 3; - break; - case GL_RGBA: - 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_SHORT: - case GL_UNSIGNED_SHORT: - esize = 2; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - esize = 2; - elements = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - esize = 4; - 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 haveGL15; -private boolean haveGL21; -private boolean haveARBVertexBufferObject; - -private void initBufferObjectExtensionChecks() { - if (bufferObjectExtensionsInitialized) - return; - bufferObjectExtensionsInitialized = true; - 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) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private boolean checkUnpackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return false; -} - -private boolean checkPackPBODisabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private boolean checkPackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return 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/**/ arbVBOCache = new HashMap(); - -/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ -public java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GL2ES12ProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ -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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 - } - - public void glVertexPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glColorPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - - } - public void glNormalPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.getComponentNumber()!=3) { - throw new GLException("Only 3 components per normal allowed"); - } - if(array.isVBO()) { - glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glTexCoordPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java b/make/config/jogl/gl-impl-CustomJavaCode-gl3.java deleted file mode 100644 index cff0b0f94..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl3.java +++ /dev/null @@ -1,468 +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; -} - -public final boolean isGL() { - return true; -} - -public final boolean isGL4bc() { - return false; -} - -public final boolean isGL4() { - return false; -} - -public final boolean isGL3bc() { - return false; -} - -public final boolean isGL3() { - return true; -} - -public final boolean isGL2() { - return false; -} - -public final boolean isGLES1() { - return false; -} - -public final boolean isGLES2() { - return false; -} - -public final boolean isGLES() { - return false; -} - -public final boolean isGL2ES1() { - return false; -} - -public final boolean isGL2ES2() { - return true; -} - -public final boolean isGL2GL3() { - return true; -} - -public final boolean hasGLSL() { - return true; -} - -public final GL getGL() throws GLException { - return this; -} - -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -public final GL3bc getGL3bc() throws GLException { - throw new GLException("Not a GL3bc implementation"); -} - -public final GL3 getGL3() throws GLException { - return this; -} - -public final GL2 getGL2() throws GLException { - throw new GLException("Not a GL2 implementation"); -} - -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); -} - -public final GL2ES1 getGL2ES1() throws GLException { - throw new GLException("Not a GLES2ES1 implementation"); -} - -public final GL2ES2 getGL2ES2() throws GLException { - return this; -} - -public final GL2GL3 getGL2GL3() throws GLException { - return this; -} - -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -/** - * 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); -} - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - -// -// 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/**/ arbVBOCache = new HashMap(); - -/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ -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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ -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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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-gl3bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java deleted file mode 100644 index 2f804a218..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl3bc.java +++ /dev/null @@ -1,514 +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 GL3bcImpl(GLProfile glp, GLContextImpl context) { - this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - this.glProfile = glp; -} - -public final boolean isGL() { - return true; -} - -public final boolean isGL4bc() { - return false; -} - -public final boolean isGL4() { - return false; -} - -public final boolean isGL3bc() { - return true; -} - -public final boolean isGL3() { - return true; -} - -public final boolean isGL2() { - return true; -} - -public final boolean isGLES1() { - return false; -} - -public final boolean isGLES2() { - return false; -} - -public final boolean isGLES() { - return false; -} - -public final boolean isGL2ES1() { - return true; -} - -public final boolean isGL2ES2() { - return true; -} - -public final boolean isGL2GL3() { - return true; -} - -public final boolean hasGLSL() { - return true; -} - -public final GL getGL() throws GLException { - return this; -} - -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -public final GL3bc getGL3bc() throws GLException { - return this; -} - -public final GL3 getGL3() throws GLException { - return this; -} - -public final GL2 getGL2() throws GLException { - return this; -} - -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); -} - -public final GL2ES1 getGL2ES1() throws GLException { - return this; -} - -public final GL2ES2 getGL2ES2() throws GLException { - return this; -} - -public final GL2GL3 getGL2GL3() throws GLException { - return this; -} - -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -/** - * 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); -} - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - -// -// 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_COLOR_INDEX: - 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: - case GL_ABGR_EXT: - elements = 4; - break; - /* FIXME ?? - case GL_HILO_NV: - elements = 2; - break; */ - default: - return 0; - } - switch (type) { - case GL_BITMAP: - if (format == GL_COLOR_INDEX) { - return (d * (h * ((w+7)/8))); - } else { - return 0; - } - 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/**/ arbVBOCache = new HashMap(); - -/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ -public java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GL3bcProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ -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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 - } - - public void glVertexPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glColorPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - - } - public void glNormalPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.getComponentNumber()!=3) { - throw new GLException("Only 3 components per normal allowed"); - } - if(array.isVBO()) { - glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - public void glTexCoordPointer(GLArrayData array) { - if(array.getComponentNumber()==0) return; - if(array.isVBO()) { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); - } else { - glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); - } - } - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4.java new file mode 100644 index 000000000..a2c70eeee --- /dev/null +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4.java @@ -0,0 +1,339 @@ +// 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/**/ arbVBOCache = new HashMap(); + +/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ +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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ +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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 new file mode 100644 index 000000000..bceb12fe5 --- /dev/null +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -0,0 +1,385 @@ +// 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 GL4bcImpl(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_COLOR_INDEX: + 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: + case GL_ABGR_EXT: + elements = 4; + break; + /* FIXME ?? + case GL_HILO_NV: + elements = 2; + break; */ + default: + return 0; + } + switch (type) { + case GL_BITMAP: + if (format == GL_COLOR_INDEX) { + return (d * (h * ((w+7)/8))); + } else { + return 0; + } + 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/**/ arbVBOCache = new HashMap(); + +/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ +public java.nio.ByteBuffer glMapBuffer(int target, int access) { + final long __addr_ = ((GL4bcProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ +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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 + } + + public void glVertexPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glColorPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + + } + public void glNormalPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.getComponentNumber()!=3) { + throw new GLException("Only 3 components per normal allowed"); + } + if(array.isVBO()) { + glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glTexCoordPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 6fb8a32ef..b4efac8a1 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -6,10 +6,6 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) { this.glProfile = glp; } -public final boolean isGL() { - return true; -} - public final boolean isGL4bc() { return false; } @@ -58,10 +54,6 @@ public final boolean hasGLSL() { return false; } -public final GL getGL() throws GLException { - return this; -} - public final GL4bc getGL4bc() throws GLException { throw new GLException("Not a GL4bc implementation"); } @@ -102,39 +94,6 @@ public final GL2GL3 getGL2GL3() throws GLException { throw new GLException("Not a GL2GL3 implementation"); } -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - // // Helpers for ensuring the correct amount of texture data // diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index 8204bd1ae..bb8ddb7ef 100755 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -10,10 +10,6 @@ public GLES2Impl(GLProfile glp, GLContextImpl context) { this.glProfile = glp; } -public final boolean isGL() { - return true; -} - public final boolean isGL4bc() { return false; } @@ -62,10 +58,6 @@ public final boolean hasGLSL() { return true; } -public final GL getGL() throws GLException { - return this; -} - public final GL4bc getGL4bc() throws GLException { throw new GLException("Not a GL4bc implementation"); } @@ -106,39 +98,6 @@ public final GL2GL3 getGL2GL3() throws GLException { throw new GLException("Not a GL2GL3 implementation"); } -public boolean isFunctionAvailable(String glFunctionName) { - return _context.isFunctionAvailable(glFunctionName); -} - -public boolean isExtensionAvailable(String glExtensionName) { - return _context.isExtensionAvailable(glExtensionName); -} - -public Object getExtension(String extensionName) { - // At this point we don't expose any extensions using this mechanism - return null; -} - -/** Returns the context this GL object is associated with for better - error checking by DebugGL. */ -public GLContext getContext() { - return _context; -} - -private GLContextImpl _context; - -public void setSwapInterval(int interval) { - _context.setSwapInterval(interval); -} - -public int getSwapInterval() { - return _context.getSwapInterval(); -} - -public Object getPlatformGLExtensions() { - return _context.getPlatformGLExtensions(); -} - // // Helpers for ensuring the correct amount of texture data // diff --git a/make/config/jogl/gl3-common.cfg b/make/config/jogl/gl3-common.cfg index fac8323bb..c2cc2968e 100644 --- a/make/config/jogl/gl3-common.cfg +++ b/make/config/jogl/gl3-common.cfg @@ -16,6 +16,9 @@ RenameExtensionIntoCore GL_ARB_geometry_shader4 RenameExtensionIntoCore GL_ARB_sync # <<< OpenGL 3.2 +# >>> OpenGL 3.3 +# <<< OpenGL 3.3 + # Ignore GL functions that deal with explicit pointer values in such a # way that we cannot implement the functionality in Java Ignore glMultiDrawElementsBaseVertex diff --git a/make/config/jogl/gl3-desktop-tracker.cfg b/make/config/jogl/gl3-desktop-tracker.cfg deleted file mode 100644 index 4b9a7edb7..000000000 --- a/make/config/jogl/gl3-desktop-tracker.cfg +++ /dev/null @@ -1,38 +0,0 @@ - -# Track server-side object creation and deletion when necessary -# Note that this is only necessary when the Java 2D / JOGL bridge is active, -# so will never be needed for the embedded OpenGL variants -JavaEpilogue glGenBuffers if (tracker != null) tracker.addBuffers({0}, {1}); -JavaEpilogue glGenFencesAPPLE if (tracker != null) tracker.addFencesAPPLE({0}, {1}); -JavaEpilogue glGenFencesNV if (tracker != null) tracker.addFencesNV({0}, {1}); -JavaEpilogue glGenFragmentShadersATI if (tracker != null) tracker.addFragmentShadersATI(_res, {0}); -JavaEpilogue glGenFramebuffersEXT if (tracker != null) tracker.addFramebuffersEXT({0}, {1}); -JavaEpilogue glGenLists if (tracker != null) tracker.addLists(_res, {0}); -JavaEpilogue glGenOcclusionQueriesNV if (tracker != null) tracker.addOcclusionQueriesNV({0}, {1}); -JavaEpilogue glCreateProgram if (tracker != null) tracker.addProgramObject(_res); -JavaEpilogue glGenPrograms if (tracker != null) tracker.addPrograms({0}, {1}); -JavaEpilogue glGenQueries if (tracker != null) tracker.addQueries({0}, {1}); -JavaEpilogue glGenRenderbuffersEXT if (tracker != null) tracker.addRenderbuffersEXT({0}, {1}); -JavaEpilogue glCreateShader if (tracker != null) tracker.addShaderObject(_res); -JavaEpilogue glGenTextures if (tracker != null) tracker.addTextures({0}, {1}); -JavaEpilogue glGenVertexArraysAPPLE if (tracker != null) tracker.addVertexArraysAPPLE({0}, {1}); -JavaEpilogue glGenVertexShadersEXT if (tracker != null) tracker.addVertexShadersEXT(_res, {0}); - -JavaEpilogue glDeleteBuffers if (tracker != null) tracker.removeBuffers({0}, {1}); -JavaEpilogue glDeleteFencesAPPLE if (tracker != null) tracker.removeFencesAPPLE({0}, {1}); -JavaEpilogue glDeleteFencesNV if (tracker != null) tracker.removeFencesNV({0}, {1}); -JavaEpilogue glDeleteFragmentShaderATI if (tracker != null) tracker.removeFragmentShaderATI({0}); -JavaEpilogue glDeleteFramebuffersEXT if (tracker != null) tracker.removeFramebuffersEXT({0}, {1}); -JavaEpilogue glDeleteLists if (tracker != null) tracker.removeLists({0}, {1}); -JavaEpilogue glDeleteOcclusionQueriesNV if (tracker != null) tracker.removeOcclusionQueriesNV({0}, {1}); -JavaEpilogue glDeleteProgram if (tracker != null) tracker.removeProgramObject({0}); -JavaEpilogue glDeleteObject if (tracker != null) tracker.removeProgramOrShaderObject({0}); -JavaEpilogue glDeletePrograms if (tracker != null) tracker.removePrograms({0}, {1}); -JavaEpilogue glDeleteProgramsNV if (tracker != null) tracker.removeProgramsNV({0}, {1}); -JavaEpilogue glDeleteQueries if (tracker != null) tracker.removeQueries({0}, {1}); -JavaEpilogue glDeleteRenderbuffersEXT if (tracker != null) tracker.removeRenderbuffersEXT({0}, {1}); -JavaEpilogue glDeleteShader if (tracker != null) tracker.removeShaderObject({0}); -JavaEpilogue glDeleteTextures if (tracker != null) tracker.removeTextures({0}, {1}); -JavaEpilogue glDeleteVertexArraysAPPLE if (tracker != null) tracker.removeVertexArraysAPPLE({0}, {1}); -JavaEpilogue glDeleteVertexShaderEXT if (tracker != null) tracker.removeVertexShaderEXT({0}); - diff --git a/make/config/jogl/gl4-common.cfg b/make/config/jogl/gl4-common.cfg new file mode 100644 index 000000000..2c119da30 --- /dev/null +++ b/make/config/jogl/gl4-common.cfg @@ -0,0 +1,5 @@ + +# >>> OpenGL 4.0 +# <<< OpenGL 4.0 + + diff --git a/make/config/jogl/gl4-desktop-tracker.cfg b/make/config/jogl/gl4-desktop-tracker.cfg new file mode 100644 index 000000000..4b9a7edb7 --- /dev/null +++ b/make/config/jogl/gl4-desktop-tracker.cfg @@ -0,0 +1,38 @@ + +# Track server-side object creation and deletion when necessary +# Note that this is only necessary when the Java 2D / JOGL bridge is active, +# so will never be needed for the embedded OpenGL variants +JavaEpilogue glGenBuffers if (tracker != null) tracker.addBuffers({0}, {1}); +JavaEpilogue glGenFencesAPPLE if (tracker != null) tracker.addFencesAPPLE({0}, {1}); +JavaEpilogue glGenFencesNV if (tracker != null) tracker.addFencesNV({0}, {1}); +JavaEpilogue glGenFragmentShadersATI if (tracker != null) tracker.addFragmentShadersATI(_res, {0}); +JavaEpilogue glGenFramebuffersEXT if (tracker != null) tracker.addFramebuffersEXT({0}, {1}); +JavaEpilogue glGenLists if (tracker != null) tracker.addLists(_res, {0}); +JavaEpilogue glGenOcclusionQueriesNV if (tracker != null) tracker.addOcclusionQueriesNV({0}, {1}); +JavaEpilogue glCreateProgram if (tracker != null) tracker.addProgramObject(_res); +JavaEpilogue glGenPrograms if (tracker != null) tracker.addPrograms({0}, {1}); +JavaEpilogue glGenQueries if (tracker != null) tracker.addQueries({0}, {1}); +JavaEpilogue glGenRenderbuffersEXT if (tracker != null) tracker.addRenderbuffersEXT({0}, {1}); +JavaEpilogue glCreateShader if (tracker != null) tracker.addShaderObject(_res); +JavaEpilogue glGenTextures if (tracker != null) tracker.addTextures({0}, {1}); +JavaEpilogue glGenVertexArraysAPPLE if (tracker != null) tracker.addVertexArraysAPPLE({0}, {1}); +JavaEpilogue glGenVertexShadersEXT if (tracker != null) tracker.addVertexShadersEXT(_res, {0}); + +JavaEpilogue glDeleteBuffers if (tracker != null) tracker.removeBuffers({0}, {1}); +JavaEpilogue glDeleteFencesAPPLE if (tracker != null) tracker.removeFencesAPPLE({0}, {1}); +JavaEpilogue glDeleteFencesNV if (tracker != null) tracker.removeFencesNV({0}, {1}); +JavaEpilogue glDeleteFragmentShaderATI if (tracker != null) tracker.removeFragmentShaderATI({0}); +JavaEpilogue glDeleteFramebuffersEXT if (tracker != null) tracker.removeFramebuffersEXT({0}, {1}); +JavaEpilogue glDeleteLists if (tracker != null) tracker.removeLists({0}, {1}); +JavaEpilogue glDeleteOcclusionQueriesNV if (tracker != null) tracker.removeOcclusionQueriesNV({0}, {1}); +JavaEpilogue glDeleteProgram if (tracker != null) tracker.removeProgramObject({0}); +JavaEpilogue glDeleteObject if (tracker != null) tracker.removeProgramOrShaderObject({0}); +JavaEpilogue glDeletePrograms if (tracker != null) tracker.removePrograms({0}, {1}); +JavaEpilogue glDeleteProgramsNV if (tracker != null) tracker.removeProgramsNV({0}, {1}); +JavaEpilogue glDeleteQueries if (tracker != null) tracker.removeQueries({0}, {1}); +JavaEpilogue glDeleteRenderbuffersEXT if (tracker != null) tracker.removeRenderbuffersEXT({0}, {1}); +JavaEpilogue glDeleteShader if (tracker != null) tracker.removeShaderObject({0}); +JavaEpilogue glDeleteTextures if (tracker != null) tracker.removeTextures({0}, {1}); +JavaEpilogue glDeleteVertexArraysAPPLE if (tracker != null) tracker.removeVertexArraysAPPLE({0}, {1}); +JavaEpilogue glDeleteVertexShaderEXT if (tracker != null) tracker.removeVertexShaderEXT({0}); + diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java index aeb4f2ef9..480f5d117 100755 --- a/make/config/jogl/glu-CustomJavaCode-base.java +++ b/make/config/jogl/glu-CustomJavaCode-base.java @@ -169,7 +169,7 @@ protected static boolean checkedGLUtessellatorImpl = false; protected static final void validateGLUtessellatorImpl() { if(!checkedGLUtessellatorImpl) { - availableGLUtessellatorImpl = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl"); + availableGLUtessellatorImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl"); checkedGLUtessellatorImpl = true; } if(!availableGLUtessellatorImpl) { @@ -1220,7 +1220,7 @@ protected static final void validateGLUquadricImpl() { if(!checkedGLUquadricImpl) { synchronized (syncObject) { if(!checkedGLUquadricImpl) { - availableGLUquadricImpl = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl"); + availableGLUquadricImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl"); checkedGLUquadricImpl = true; } } diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java index b5cb3b2f8..f3b4322d9 100755 --- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java @@ -86,7 +86,7 @@ protected static boolean checkedMipmap = false; protected static final void validateMipmap() { if(!checkedMipmap) { - availableMipmap = NWReflection.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap"); + availableMipmap = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap"); checkedMipmap = true; } if(!availableMipmap) { diff --git a/make/config/jogl/glu-common.cfg b/make/config/jogl/glu-common.cfg index 937ca0348..f5fc7c1b3 100644 --- a/make/config/jogl/glu-common.cfg +++ b/make/config/jogl/glu-common.cfg @@ -14,7 +14,7 @@ Import javax.media.opengl.glu.* Import com.jogamp.opengl.impl.* Import com.jogamp.opengl.impl.glu.* Import com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl -Import com.jogamp.nativewindow.impl.NWReflection +Import com.jogamp.common.util.ReflectionUtil # Raise GLException instead of RuntimeException in glue code RuntimeExceptionType GLException diff --git a/make/config/jogl/obsolete/gl-gl2es12.cfg b/make/config/jogl/obsolete/gl-gl2es12.cfg new file mode 100644 index 000000000..3942b1419 --- /dev/null +++ b/make/config/jogl/obsolete/gl-gl2es12.cfg @@ -0,0 +1,90 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/gl2es12 + +ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java +ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/GLBase.java +ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java +ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java +ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java + +Style ImplOnly +ImplPackage com.jogamp.opengl.impl.gl2es12 +ImplJavaClass GL2ES12Impl +Implements GL2ES12Impl GLBase +Implements GL2ES12Impl GL +Implements GL2ES12Impl GL2ES1 +Implements GL2ES12Impl GL2ES2 + +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 +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +EmitProcAddressTable true +ProcAddressTableClassName GL2ES12ProcAddressTable +GetProcAddressTableExpr ((GL2ES12ProcAddressTable)_context.getGLProcAddressTable()) + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# There seem to be some errors in the glue code generation where we are not ignoring +# enough routines from desktop GL in GL2ES12Impl. For now manually ignore those which +# we know shouldn't be in there +Ignore glGetTexImage +Ignore glPixelStoref + +# Add PixelStorei StateTracker +# +# Add input validation to glPixelStorei to make sure that, even if we +# are running on top of desktop OpenGL, parameters not exposed in +# OpenGL ES can not be changed +CustomJavaCode GL2ES12Impl private static final int params_offset = 0; // just a helper for JavaPrologue .. + +JavaPrologue glPixelStorei if (pname != GL_PACK_ALIGNMENT && pname != GL_UNPACK_ALIGNMENT) { +JavaPrologue glPixelStorei throw new GLException("Unsupported pixel store parameter name 0x" + Integer.toHexString(pname)); +JavaPrologue glPixelStorei } +JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); + +JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } + +CustomJavaCode GL2ES12Impl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { +CustomJavaCode GL2ES12Impl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } + +CustomJavaCode GL2ES12Impl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { +CustomJavaCode GL2ES12Impl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } + +CustomJavaCode GL2ES12Impl public void glClearDepthf(float depth) { +CustomJavaCode GL2ES12Impl glClearDepth((double)depth); } + +CustomJavaCode GL2ES12Impl public void glDepthRangef(float zNear, float zFar) { +CustomJavaCode GL2ES12Impl glDepthRange((double)zNear, (double)zFar); } + +Include gl-headers.cfg +Include ../intptr.cfg + +IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-common.java +IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2es12.java +IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-embedded.java +IncludeAs CustomJavaCode GL2ES12Impl gl-impl-CustomJavaCode-gl2_es2.java +IncludeAs CustomCCode gl-impl-CustomCCode-gl2es12.c + +Import javax.media.opengl.GLES1 +Import javax.media.opengl.GLES2 +Import com.jogamp.opengl.impl.InternalBufferUtil +Import java.io.PrintStream diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c new file mode 100644 index 000000000..91fd0078b --- /dev/null +++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2.c @@ -0,0 +1,24 @@ +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl2.GL2Impl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opengl_impl_gl2_GL2Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { + PFNGLMAPBUFFERPROC ptr_glMapBuffer; + void * _res; + ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; + assert(ptr_glMapBuffer != NULL); + _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl2.GL2Impl + * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + */ +JNIEXPORT jobject JNICALL +Java_com_jogamp_opengl_impl_gl2_GL2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { + return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); +} diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c new file mode 100644 index 000000000..07b821802 --- /dev/null +++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl2es12.c @@ -0,0 +1,24 @@ +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { + PFNGLMAPBUFFERPROC ptr_glMapBuffer; + void * _res; + ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; + assert(ptr_glMapBuffer != NULL); + _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl2es12.GL2ES12Impl + * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + */ +JNIEXPORT jobject JNICALL +Java_com_jogamp_opengl_impl_gl2es12_GL2ES12Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { + return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); +} diff --git a/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c new file mode 100644 index 000000000..f540a7d4a --- /dev/null +++ b/make/config/jogl/obsolete/gl-impl-CustomCCode-gl3.c @@ -0,0 +1,24 @@ +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl3.GL3Impl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_com_jogamp_opengl_impl_gl3_GL3Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unused, jint target, jint access, jlong glProcAddress) { + PFNGLMAPBUFFERPROC ptr_glMapBuffer; + void * _res; + ptr_glMapBuffer = (PFNGLMAPBUFFERPROC) (intptr_t) glProcAddress; + assert(ptr_glMapBuffer != NULL); + _res = (* ptr_glMapBuffer) ((GLenum) target, (GLenum) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: com.jogamp.opengl.impl.gl3.GL3Impl + * Java method: ByteBuffer newDirectByteBuffer(long addr, int capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jint capacity); + */ +JNIEXPORT jobject JNICALL +Java_com_jogamp_opengl_impl_gl3_GL3Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jint capacity) { + return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); +} diff --git a/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java new file mode 100644 index 000000000..a1a6917df --- /dev/null +++ b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2.java @@ -0,0 +1,385 @@ +// 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 GL2Impl(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_COLOR_INDEX: + 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: + case GL_ABGR_EXT: + elements = 4; + break; + /* FIXME ?? + case GL_HILO_NV: + elements = 2; + break; */ + default: + return 0; + } + switch (type) { + case GL_BITMAP: + if (format == GL_COLOR_INDEX) { + return (d * (h * ((w+7)/8))); + } else { + return 0; + } + 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/**/ arbVBOCache = new HashMap(); + +/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ +public java.nio.ByteBuffer glMapBuffer(int target, int access) { + final long __addr_ = ((GL2ProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ +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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 + } + + public void glVertexPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glColorPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + + } + public void glNormalPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.getComponentNumber()!=3) { + throw new GLException("Only 3 components per normal allowed"); + } + if(array.isVBO()) { + glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glTexCoordPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + diff --git a/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java new file mode 100644 index 000000000..aed442da3 --- /dev/null +++ b/make/config/jogl/obsolete/gl-impl-CustomJavaCode-gl2es12.java @@ -0,0 +1,353 @@ +// 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 GL2ES12Impl(GLProfile glp, GLContextImpl context) { + this._context = context; + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + this.isGL2ES2 = glp.isGL2ES2(); + this.glProfile = glp; +} + +private boolean isGL2ES2; + +public boolean isFunctionAvailable(String glFunctionName) { + return _context.isFunctionAvailable(glFunctionName); +} + +public boolean isExtensionAvailable(String glExtensionName) { + return _context.isExtensionAvailable(glExtensionName); +} + +public Object getExtension(String extensionName) { + // At this point we don't expose any extensions using this mechanism + return null; +} + +/** Returns the context this GL object is associated with for better + error checking by DebugGL. */ +public GLContext getContext() { + return _context; +} + +private GLContextImpl _context; + +public void setSwapInterval(int interval) { + _context.setSwapInterval(interval); +} + +public int getSwapInterval() { + return _context.getSwapInterval(); +} + +public Object getPlatformGLExtensions() { + return _context.getPlatformGLExtensions(); +} + +// +// 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_ALPHA: + case GL_LUMINANCE: + case GL_DEPTH_COMPONENT: + elements = 1; + break; + case GL_LUMINANCE_ALPHA: + elements = 2; + break; + case GL_RGB: + elements = 3; + break; + case GL_RGBA: + 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_SHORT: + case GL_UNSIGNED_SHORT: + esize = 2; + break; + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + esize = 2; + elements = 1; + break; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + esize = 4; + 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 haveGL15; +private boolean haveGL21; +private boolean haveARBVertexBufferObject; + +private void initBufferObjectExtensionChecks() { + if (bufferObjectExtensionsInitialized) + return; + bufferObjectExtensionsInitialized = true; + 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) { + // PBO n/a for ES 1.1 or ES 2.0 + return true; +} + +private boolean checkUnpackPBOEnabled(boolean throwException) { + // PBO n/a for ES 1.1 or ES 2.0 + return false; +} + +private boolean checkPackPBODisabled(boolean throwException) { + // PBO n/a for ES 1.1 or ES 2.0 + return true; +} + +private boolean checkPackPBOEnabled(boolean throwException) { + // PBO n/a for ES 1.1 or ES 2.0 + return 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/**/ arbVBOCache = new HashMap(); + +/** Entry point to C language function:
LPVOID glMapBuffer(GLenum target, GLenum access); */ +public java.nio.ByteBuffer glMapBuffer(int target, int access) { + final long __addr_ = ((GL2ES12ProcAddressTable)_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
: LPVOID glMapBuffer(GLenum target, GLenum access); */ +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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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:
void {@native glShaderBinary}(GLint n, const GLuint * shaders, GLenum binaryformat, const void * binary, GLint length);
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 + } + + public void glVertexPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glVertexPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glColorPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glColorPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + + } + public void glNormalPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.getComponentNumber()!=3) { + throw new GLException("Only 3 components per normal allowed"); + } + if(array.isVBO()) { + glNormalPointer(array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + public void glTexCoordPointer(GLArrayData array) { + if(array.getComponentNumber()==0) return; + if(array.isVBO()) { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getOffset()); + } else { + glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer()); + } + } + + diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 57f37bee7..44bb1e8d0 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -26,9 +26,8 @@ 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 void DestroyDummyWindow(long display, long window); public static native long dlopen(String name); public static native long dlsym(String name); -- cgit v1.2.3